cosmos-sdk/docs/building-modules/intro.md

93 lines
8.0 KiB
Markdown
Raw Normal View History

Docs: hide frontmatter, bugfixes (#5413) * 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
2019-12-17 03:44:44 -08:00
<!--
Update docs website (#5827) * 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 * scrollbar color * move synopsis from frontmatter * move synopsis from frontmatter * code styling in synopsis fix * tutorial link * active headers * 404 fix * homepage links fix * fix link in footer * misc fixes * version * prerequisite links on mobile * version * version * Fix footer links * version * Fix permalink popup * Update version * package-lock.json * Update Questions section in the footer * Config for Algolia Docsearch * Update version * Update to the latest version of the theme * Use docs-staging as a branch for staging website * Update version * Add google analytics * Remove {hide} from Pre-Requisite Readings * Replace Riot with Discord Co-Authored-By: billy rennekamp <billy.rennekamp@gmail.com> * Fix yaml syntax error in docs * Fix formatting in keyring.md Co-authored-by: Gloria Zhao <gzhao408@berkeley.edu> Co-authored-by: gamarin <gautier@tendermint.com> Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com> Co-authored-by: Hans Schoenburg <hschoenburg@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: billy rennekamp <billy.rennekamp@gmail.com>
2020-03-24 09:20:30 -07:00
order: 1
Docs: hide frontmatter, bugfixes (#5413) * 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
2019-12-17 03:44:44 -08:00
-->
# Introduction to SDK Modules
Update docs website (#5827) * 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 * scrollbar color * move synopsis from frontmatter * move synopsis from frontmatter * code styling in synopsis fix * tutorial link * active headers * 404 fix * homepage links fix * fix link in footer * misc fixes * version * prerequisite links on mobile * version * version * Fix footer links * version * Fix permalink popup * Update version * package-lock.json * Update Questions section in the footer * Config for Algolia Docsearch * Update version * Update to the latest version of the theme * Use docs-staging as a branch for staging website * Update version * Add google analytics * Remove {hide} from Pre-Requisite Readings * Replace Riot with Discord Co-Authored-By: billy rennekamp <billy.rennekamp@gmail.com> * Fix yaml syntax error in docs * Fix formatting in keyring.md Co-authored-by: Gloria Zhao <gzhao408@berkeley.edu> Co-authored-by: gamarin <gautier@tendermint.com> Co-authored-by: Jack Zampolin <jack.zampolin@gmail.com> Co-authored-by: Hans Schoenburg <hschoenburg@users.noreply.github.com> Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> Co-authored-by: Alexander Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: billy rennekamp <billy.rennekamp@gmail.com>
2020-03-24 09:20:30 -07:00
Modules define most of the logic of SDK applications. Developers compose module together using the Cosmos SDK to build their custom application-specific blockchains. This document outlines the basic concepts behind SDK modules and how to approach module management. {synopsis}
## Pre-requisite Readings
- [Anatomy of an SDK application](../basics/app-anatomy.md) {prereq}
- [Lifecycle of an SDK transaction](../basics/tx-lifecycle.md) {prereq}
## Role of Modules in an SDK Application
The Cosmos SDK can be thought as the Ruby-on-Rails of blockchain development. It comes with a core that provides the basic functionalities every blockchain application needs, like a [boilerplate implementation of the ABCI](../core/baseapp.md) to communicate with the underlying consensus engine, a [`multistore`](../core/store.md#multistore) to persist state, a [server](../core/node.md) to form a full-node and [interfaces](./module-interfaces.md) to handle queries.
On top of this core, the Cosmos SDK enables developers to build modules that implement the business logic of their application. In other words, SDK modules implement the bulk of the logic of applications, while the core does the wiring and enables modules to be composed together. The end goal is to build a robust ecosystem of open-source SDK modules, making it increasingly easier to build complex blockchain applications.
[docs]: update building modules section to reflect ADR31 (#7702) * Revert "Revert "Update old ref of RegisterQueryService"" This reverts commit 03e4c56de53938ccbf025a441e54b9842f7c4544. * Update intro, module-manager and messages-and-queries * Update messages-and-queries * Update handler * Update structure * Add doc related to RegisterMsgServiceDesc * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/messages-and-queries.md * Update handler.md * Rename handler.md to msg-services.md * Update legacy msgs wording * Update messages-and-queries.md * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/intro.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Remove handler mention from intro.md * Update docs/building-modules/messages-and-queries.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/keeper.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Address review comments * Use tag * Update docs/building-modules/intro.md Co-authored-by: Cory <cjlevinson@gmail.com> * Update docs/building-modules/intro.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/transactions.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Remove framework related explanation from docs * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/module-manager.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/module-manager.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update beginblock-endblock.md * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/transactions.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Add deprecated notice * Update tx-lifecycle.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Cory <cjlevinson@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-11-17 12:41:43 -08:00
SDK Modules can be seen as little state-machines within the state-machine. They generally define a subset of the state using one or more `KVStore`s in the [main multistore](../core/store.md), as well as a subset of [message types](./messages-and-queries.md#messages). These messages are routed by one of the main component of SDK core, [`BaseApp`](../core/baseapp.md), to the [`Msg` service](./msg-services.md) of the module that define them.
```
+
|
| Transaction relayed from the full-node's consensus engine
| to the node's application via DeliverTx
|
|
|
+---------------------v--------------------------+
| APPLICATION |
| |
| Using baseapp's methods: Decode the Tx, |
| extract and route the message(s) |
| |
+---------------------+--------------------------+
|
|
|
+---------------------------+
|
|
|
| Message routed to the correct
| module to be processed
|
|
+----------------+ +---------------+ +----------------+ +------v----------+
| | | | | | | |
| AUTH MODULE | | BANK MODULE | | STAKING MODULE | | GOV MODULE |
| | | | | | | |
| | | | | | | Handles message,|
| | | | | | | Updates state |
| | | | | | | |
+----------------+ +---------------+ +----------------+ +------+----------+
|
|
|
|
+--------------------------+
|
| Return result to the underlying consensus engine (e.g. Tendermint)
| (0=Ok, 1=Err)
v
```
As a result of this architecture, building an SDK application usually revolves around writing modules to implement the specialized logic of the application, and composing them with existing modules to complete the application. Developers will generally work on modules that implement logic needed for their specific use case that do not exist yet, and will use existing modules for more generic functionalities like staking, accounts or token management.
## How to Approach Building Modules as a Developer
While there are no definitive guidelines for writing modules, here are some important design principles developers should keep in mind when building them:
- **Composability**: SDK applications are almost always composed of multiple modules. This means developers need to carefully consider the integration of their module not only with the core of the Cosmos SDK, but also with other modules. The former is achieved by following standard design patterns outlined [here](#main-components-of-sdk-modules), while the latter is achieved by properly exposing the store(s) of the module via the [`keeper`](./keeper.md).
- **Specialization**: A direct consequence of the **composability** feature is that modules should be **specialized**. Developers should carefully establish the scope of their module and not batch multiple functionalities into the same module. This separation of concern enables modules to be re-used in other projects and improves the upgradability of the application. **Specialization** also plays an important role in the [object-capabilities model](../core/ocap.md) of the Cosmos SDK.
- **Capabilities**: Most modules need to read and/or write to the store(s) of other modules. However, in an open-source environment, it is possible for some module to be malicious. That is why module developers need to carefully think not only about how their module interacts with other modules, but also about how to give access to the module's store(s). The Cosmos SDK takes a capabilities-oriented approach to inter-module security. This means that each store defined by a module is accessed by a `key`, which is held by the module's [`keeper`](./keeper.md). This `keeper` defines how to access the store(s) and under what conditions. Access to the module's store(s) is done by passing a reference to the module's `keeper`.
## Main Components of SDK Modules
[docs]: update building modules section to reflect ADR31 (#7702) * Revert "Revert "Update old ref of RegisterQueryService"" This reverts commit 03e4c56de53938ccbf025a441e54b9842f7c4544. * Update intro, module-manager and messages-and-queries * Update messages-and-queries * Update handler * Update structure * Add doc related to RegisterMsgServiceDesc * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/messages-and-queries.md * Update handler.md * Rename handler.md to msg-services.md * Update legacy msgs wording * Update messages-and-queries.md * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/intro.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Remove handler mention from intro.md * Update docs/building-modules/messages-and-queries.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/keeper.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Address review comments * Use tag * Update docs/building-modules/intro.md Co-authored-by: Cory <cjlevinson@gmail.com> * Update docs/building-modules/intro.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/transactions.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Remove framework related explanation from docs * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/module-manager.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/module-manager.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update beginblock-endblock.md * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/transactions.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Add deprecated notice * Update tx-lifecycle.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Cory <cjlevinson@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-11-17 12:41:43 -08:00
Modules are by convention defined in the `./x/` subfolder (e.g. the `bank` module will be defined in the `./x/bank` folder). They generally share the same core components:
[docs]: update building modules section to reflect ADR31 (#7702) * Revert "Revert "Update old ref of RegisterQueryService"" This reverts commit 03e4c56de53938ccbf025a441e54b9842f7c4544. * Update intro, module-manager and messages-and-queries * Update messages-and-queries * Update handler * Update structure * Add doc related to RegisterMsgServiceDesc * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/handler.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> * Update docs/building-modules/messages-and-queries.md * Update handler.md * Rename handler.md to msg-services.md * Update legacy msgs wording * Update messages-and-queries.md * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/intro.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Remove handler mention from intro.md * Update docs/building-modules/messages-and-queries.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/keeper.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Update docs/building-modules/msg-services.md Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> * Address review comments * Use tag * Update docs/building-modules/intro.md Co-authored-by: Cory <cjlevinson@gmail.com> * Update docs/building-modules/intro.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/transactions.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Remove framework related explanation from docs * Update docs/building-modules/messages-and-queries.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/module-manager.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/module-manager.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/building-modules/msg-services.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update beginblock-endblock.md * Update docs/core/baseapp.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Update docs/core/transactions.md Co-authored-by: Aaron Craelius <aaron@regen.network> * Add deprecated notice * Update tx-lifecycle.md Co-authored-by: Robert Zaremba <robert@zaremba.ch> Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com> Co-authored-by: Aaron Craelius <aaron@regen.network> Co-authored-by: Cory <cjlevinson@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-11-17 12:41:43 -08:00
- A [`keeper`](./keeper.md), used to access the module's store(s) and update the state.
- A [`Msg` service](./messages-and-queries.md#messages) used to process messages when they are routed to the module by [`BaseApp`](../core/baseapp.md#message-routing) and trigger state-transitions.
- A [query service](./query-services.md), used to process user queries when they are routed to the module by [`BaseApp`](../core/baseapp.md#query-routing).
- Interfaces, for end users to query the subset of the state defined by the module and create `message`s of the custom types defined in the module.
In addition to these components, modules implement the `AppModule` interface in order to be managed by the [`module manager`](./module-manager.md).
Please refer to the [structure document](./structure.md) to learn about the recommended structure of a module's directory.
## Next {hide}
Read more on the [`AppModule` interface and the `module manager`](./module-manager.md) {hide}