Skip to content

Commit

Permalink
feat(internal/tools): improve config doc (#4155)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantani committed May 19, 2024
1 parent 6a65f9c commit 6f8df69
Show file tree
Hide file tree
Showing 12 changed files with 232 additions and 126 deletions.
89 changes: 89 additions & 0 deletions docs/docs/08-references/03-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
sidebar_position: 4
description: Configuration file example.
title: Configuration file example
---

## Configuration file example

```yaml title="config.yml"
validation: (string) # Specifies the type of validation the blockchain uses (e.g., sovereign).
version: (uint) # Defines the configuration version number.
build: # Contains build configuration options.
main: (string) # Path to the main build file.
binary: (string) # Path to the binary file.
ldflags: (string list) # List of custom linker flags for building the binary.
proto: # Contains proto build configuration options.
path: (string) # Relative path where the application's proto files are located.
third_party_paths: (string list) # Relative paths to third-party proto files used by the application.
accounts: (list) # Lists the options for setting up Cosmos Accounts.
name: (string) # Local name associated with the Account's key pair.
coins: (string list) # List of token balances for the account.
mnemonic: (string) # Mnemonic phrase for the account.
address: (string) # Address of the account.
cointype: (string) # Coin type number for HD derivation (default is 118).
account_number: (string) # Account number for HD derivation (must be ≤ 2147483647).
address_index: (string) # Address index number for HD derivation (must be ≤ 2147483647).
faucet: # Configuration for the faucet.
name: (string) # Name of the faucet account.
coins: (string list) # Types and amounts of coins the faucet distributes.
coins_max: (string list) # Maximum amounts of coins that can be transferred to a single user.
rate_limit_window: (string) # Timeframe after which the limit will be refreshed.
host: (string) # Host address of the faucet server.
port: (uint) # Port number for the faucet server.
client: # Configures client code generation.
typescript: # Relative path where the application's Typescript files are located.
path: (string) # Relative path where the application's Typescript files are located.
composables: # Configures Vue 3 composables code generation.
path: (string) # Relative path where the application's composable files are located.
hooks: # Configures React hooks code generation.
path: (string) # Relative path where the application's hooks files are located.
openapi: # Configures OpenAPI spec generation for the API.
path: (string) # Relative path where the application's OpenAPI files are located.
genesis: (key/value) # Custom genesis block modifications. Follow the nesting of the genesis file here to access all the parameters.
minimal: (bool) # Indicates if the blockchain is minimal with the required Cosmos SDK modules.
validators: (list) # Contains information related to the list of validators and settings.
name: (string) # Name of the validator.
bonded: (string) # Amount staked by the validator.
app: (key/value) # Overwrites the appd's config/app.toml configurations.
config: (key/value) # Overwrites the appd's config/config.toml configurations.
client: (key/value) # Overwrites the appd's config/client.toml configurations.
home: (string) # Overwrites the default home directory used for the application.
gentx: # Overwrites the appd's config/gentx.toml configurations.
amount: (string) # Amount for the current Gentx.
moniker: (string) # Optional moniker for the validator.
home: (string) # Directory for configuration and data.
keyring-backend: (string) # Backend for the keyring.
chain-id: (string) # Network chain ID.
commission-max-change-rate: (string) # Maximum commission change rate percentage per day.
commission-max-rate: (string) # Maximum commission rate percentage (e.g., 0.01 = 1%).
commission-rate: (string) # Initial commission rate percentage (e.g., 0.01 = 1%).
details: (string) # Optional details about the validator.
security-contact: (string) # Optional security contact email for the validator.
website: (string) # Optional website for the validator.
account-number: (int) # Account number of the signing account (offline mode only).
broadcast-mode: (string) # Transaction broadcasting mode (sync|async|block) (default is 'sync').
dry-run: (bool) # Simulates the transaction without actually performing it, ignoring the --gas flag.
fee-account: (string) # Account that pays the transaction fees instead of the signer.
fee: (string) # Fee to pay with the transaction (e.g.: 10uatom).
from: (string) # Name or address of the private key used to sign the transaction.
gas: (string) # Gas limit per transaction; set to 'auto' to calculate sufficient gas automatically (default is 200000).
gas-adjustment: (string) # Factor to multiply against the estimated gas (default is 1).
gas-prices: (string) # Gas prices in decimal format to determine the transaction fee (e.g., 0.1uatom).
generate-only: (bool) # Creates an unsigned transaction and writes it to STDOUT.
identity: (string) # Identity signature (e.g., UPort or Keybase).
ip: (string) # Node's public IP address (default is '192.168.1.64').
keyring-dir: (string) # Directory for the client keyring; defaults to the 'home' directory if omitted.
ledger: (bool) # Uses a connected Ledger device if true.
min-self-delegation: (string) # Minimum self-delegation required for the validator.
node: (string) # <host>:<port> for the Tendermint RPC interface (default 'tcp://localhost:26657')
node-id: (string) # Node's NodeID
note: (string) # Adds a description to the transaction (formerly --memo).
offline: (bool) # Operates in offline mode, disallowing any online functionality.
output: (string) # Output format (text|json) (default 'json').
output-document: (string) # Writes the genesis transaction JSON document to the specified file instead of the default location.
pubkey: (string) # Protobuf JSON encoded public key of the validator.
sequence: (uint) # Sequence number of the signing account (offline mode only).
sign-mode: (string) # Chooses sign mode (direct|amino-json), an advanced feature.
timeout-height: (uint) # Sets a block timeout height to prevent the transaction from being committed past a certain height.
```
98 changes: 45 additions & 53 deletions ignite/config/chain/base/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,123 +10,115 @@ import (

// Account holds the options related to setting up Cosmos wallets.
type Account struct {
Name string `yaml:"name" doc:"local name of a key pair associated with an account"`
Coins []string `yaml:"coins,omitempty" doc:"list of token balances for the account"`
Mnemonic string `yaml:"mnemonic,omitempty" doc:"account mnemonic"`
Address string `yaml:"address,omitempty" doc:"account address"`
CoinType string `yaml:"cointype,omitempty" doc:"coin type number for HD derivation (default 118)"`
AccountNumber string `yaml:"account_number,omitempty" doc:"account number for HD derivation (less than equal 2147483647)"`
AddressIndex string `yaml:"address_index,omitempty" doc:"address index number for HD derivation (less than equal 2147483647)"`
Name string `yaml:"name" doc:"Local name associated with the Account's key pair."`
Coins []string `yaml:"coins,omitempty" doc:"List of token balances for the account."`
Mnemonic string `yaml:"mnemonic,omitempty" doc:"Mnemonic phrase for the account."`
Address string `yaml:"address,omitempty" doc:"Address of the account."`
CoinType string `yaml:"cointype,omitempty" doc:"Coin type number for HD derivation (default is 118)."`
AccountNumber string `yaml:"account_number,omitempty" doc:"Account number for HD derivation (must be ≤ 2147483647)."`
AddressIndex string `yaml:"address_index,omitempty" doc:"Address index number for HD derivation (must be ≤ 2147483647)."`
}

// Build holds build configs.
type Build struct {
Main string `yaml:"main,omitempty" doc:"build main path"`
Binary string `yaml:"binary,omitempty" doc:"binary path"`
LDFlags []string `yaml:"ldflags,omitempty" doc:"custom build ld flags"`
Proto Proto `yaml:"proto" doc:"holds proto build configs"`
Main string `yaml:"main,omitempty" doc:"Path to the main build file."`
Binary string `yaml:"binary,omitempty" doc:"Path to the binary file."`
LDFlags []string `yaml:"ldflags,omitempty" doc:"List of custom linker flags for building the binary."`
Proto Proto `yaml:"proto" doc:"Contains proto build configuration options."`
}

// Proto holds proto build configs.
type Proto struct {
// Path is the relative path of where app's proto files are located at.
Path string `yaml:"path" doc:"relative path of where app's proto files are located at"`
Path string `yaml:"path" doc:"Relative path where the application's proto files are located."`

// ThirdPartyPath is the relative path of where the third party proto files are
// located that used by the app.
ThirdPartyPaths []string `yaml:"third_party_paths" doc:"relative path of where the third party proto files are located that used by the app"`
ThirdPartyPaths []string `yaml:"third_party_paths" doc:"Relative paths to third-party proto files used by the application."`
}

// Client configures code generation for clients.
type Client struct {
// TSClient configures code generation for Typescript Client.
Typescript Typescript `yaml:"typescript,omitempty" doc:"configures code generation for Typescript Client"`
Typescript Typescript `yaml:"typescript,omitempty" doc:"Relative path where the application's Typescript files are located."`

// Composables configures code generation for Vue 3 composables.
Composables Composables `yaml:"composables,omitempty" doc:"configures code generation for Vue 3 composables"`
Composables Composables `yaml:"composables,omitempty" doc:"Configures Vue 3 composables code generation."`

// Hooks configures code generation for React hooks.
Hooks Hooks `yaml:"hooks,omitempty" doc:"configures code generation for React hooks"`
Hooks Hooks `yaml:"hooks,omitempty" doc:"Configures React hooks code generation."`

// OpenAPI configures OpenAPI spec generation for API.
OpenAPI OpenAPI `yaml:"openapi,omitempty" doc:"configures OpenAPI spec generation for API"`
OpenAPI OpenAPI `yaml:"openapi,omitempty" doc:"Configures OpenAPI spec generation for the API."`
}

// Typescript configures code generation for Typescript Client.
type Typescript struct {
// Path configures out location for generated Typescript Client code.
Path string `yaml:"path" doc:"relative path of where app's typescript files are located at"`
}

// Vuex configures code generation for Vuex stores.
//
// Deprecated: Will be removed eventually.
type Vuex struct {
// Path configures out location for generated Vuex stores code.
Path string `yaml:"path" doc:"relative path of where app's vuex files are located at"`
Path string `yaml:"path" doc:"Relative path where the application's Typescript files are located."`
}

// Composables configures code generation for vue-query hooks.
type Composables struct {
// Path configures out location for generated vue-query hooks.
Path string `yaml:"path" doc:"relative path of where app's composable files are located at"`
Path string `yaml:"path" doc:"Relative path where the application's composable files are located."`
}

// Hooks configures code generation for react-query hooks.
type Hooks struct {
// Path configures out location for generated vue-query hooks.
Path string `yaml:"path" doc:"relative path of where app's hooks are located at"`
Path string `yaml:"path" doc:"Relative path where the application's hooks files are located."`
}

// OpenAPI configures OpenAPI spec generation for API.
type OpenAPI struct {
Path string `yaml:"path" doc:"relative path of where app's openapi files are located at"`
Path string `yaml:"path" doc:"Relative path where the application's OpenAPI files are located."`
}

// Faucet configuration.
type Faucet struct {
// Name is faucet account's name.
Name *string `yaml:"name" doc:"faucet account's name"`
Name *string `yaml:"name" doc:"Name of the faucet account."`

// Coins holds type of coin denoms and amounts to distribute.
Coins []string `yaml:"coins" doc:"holds type of coin denoms and amounts to distribute"`
Coins []string `yaml:"coins" doc:"Types and amounts of coins the faucet distributes."`

// CoinsMax holds of chain denoms and their max amounts that can be transferred to single user.
CoinsMax []string `yaml:"coins_max,omitempty" doc:"holds of chain denoms and their max amounts that can be transferred to single user"`
CoinsMax []string `yaml:"coins_max,omitempty" doc:"Maximum amounts of coins that can be transferred to a single user."`

// LimitRefreshTime sets the timeframe at the end of which the limit will be refreshed.
RateLimitWindow string `yaml:"rate_limit_window,omitempty" doc:"sets the timeframe at the end of which the limit will be refreshed"`
RateLimitWindow string `yaml:"rate_limit_window,omitempty" doc:"Timeframe after which the limit will be refreshed."`

// Host is the host of the faucet server.
Host string `yaml:"host,omitempty" doc:"the host of the faucet server"`
Host string `yaml:"host,omitempty" doc:"Host address of the faucet server."`

// Port number for faucet server to listen at.
Port uint `yaml:"port,omitempty" doc:"number for faucet server to listen at"`
Port uint `yaml:"port,omitempty" doc:"Port number for the faucet server."`
}

// Init overwrites sdk configurations with given values.
type Init struct {
// App overwrites appd's config/app.toml configs.
App xyaml.Map `yaml:"app" doc:"overwrites appd's config/app.toml configs"`
App xyaml.Map `yaml:"app" doc:"Overwrites the appd's config/app.toml configurations."`

// Client overwrites appd's config/client.toml configs.
Client xyaml.Map `yaml:"client" doc:"overwrites appd's config/client.toml configs"`
Client xyaml.Map `yaml:"client" doc:"Overwrites the appd's config/client.toml configurations."`

// Config overwrites appd's config/config.toml configs.
Config xyaml.Map `yaml:"config" doc:"overwrites appd's config/config.toml configs"`
Config xyaml.Map `yaml:"config" doc:"Overwrites the appd's config/config.toml configurations."`

// Home overwrites default home directory used for the app.
Home string `yaml:"home" doc:"overwrites default home directory used for the app"`
Home string `yaml:"home" doc:"Overwrites the default home directory used for the application."`
}

// Host keeps configuration related to started servers.
type Host struct {
RPC string `yaml:"rpc" doc:"RPC server address"`
P2P string `yaml:"p2p" doc:"P2P server address"`
Prof string `yaml:"prof" doc:"Profiling server address"`
GRPC string `yaml:"grpc" doc:"GRPC server address"`
GRPCWeb string `yaml:"grpc-web" doc:"GRPC Web server address"`
API string `yaml:"api" doc:"API server address"`
RPC string `yaml:"rpc" doc:"RPC server address."`
P2P string `yaml:"p2p" doc:"P2P server address."`
Prof string `yaml:"prof" doc:"Profiling server address."`
GRPC string `yaml:"grpc" doc:"GRPC server address."`
GRPCWeb string `yaml:"grpc-web" doc:"GRPC Web server address."`
API string `yaml:"api" doc:"API server address."`
}

// Validation describes the kind of validation the chain has.
Expand All @@ -144,14 +136,14 @@ const (

// Config defines a struct with the fields that are common to all config versions.
type Config struct {
Validation Validation `yaml:"validation,omitempty" doc:"describes the kind of validation the chain has"`
Version version.Version `yaml:"version" doc:"defines the type for the config version number"`
Build Build `yaml:"build,omitempty" doc:"holds build configs"`
Accounts []Account `yaml:"accounts" doc:"holds the options related to setting up Cosmos wallets"`
Faucet Faucet `yaml:"faucet,omitempty" doc:"faucet configuration"`
Client Client `yaml:"client,omitempty" doc:"configures code generation for clients"`
Genesis xyaml.Map `yaml:"genesis,omitempty" doc:"custom genesis modifications"`
Minimal bool `yaml:"minimal,omitempty" doc:"minimal blockchain with the minimum required Cosmos SDK modules"`
Validation Validation `yaml:"validation,omitempty" doc:"Specifies the type of validation the blockchain uses (e.g., sovereign)."`
Version version.Version `yaml:"version" doc:"Defines the configuration version number."`
Build Build `yaml:"build,omitempty" doc:"Contains build configuration options."`
Accounts []Account `yaml:"accounts" doc:"Lists the options for setting up Cosmos Accounts."`
Faucet Faucet `yaml:"faucet,omitempty" doc:"Configuration for the faucet."`
Client Client `yaml:"client,omitempty" doc:"Configures client code generation."`
Genesis xyaml.Map `yaml:"genesis,omitempty" doc:"Custom genesis block modifications. Follow the nesting of the genesis file here to access all the parameters."`
Minimal bool `yaml:"minimal,omitempty" doc:"Indicates if the blockchain is minimal with the required Cosmos SDK modules."`
}

// GetVersion returns the config version.
Expand Down
10 changes: 5 additions & 5 deletions ignite/config/chain/v0/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
type Config struct {
base.Config `yaml:",inline"`

Validator Validator `yaml:"validator" doc:"holds info related to validator settings"`
Init base.Init `yaml:"init" doc:"overwrites sdk configurations with given values"`
Host base.Host `yaml:"host" doc:"keeps configuration related to started servers"`
Validator Validator `yaml:"validator" doc:"Contains information related to the validator and settings."`
Init base.Init `yaml:"init" doc:"Overwrites the appd's config/config.toml configurations."`
Host base.Host `yaml:"host" doc:"Keeps configuration related to started servers."`
}

// Clone returns an identical copy of the instance.
Expand All @@ -32,6 +32,6 @@ func (c *Config) Decode(r io.Reader) error {

// Validator holds info related to validator settings.
type Validator struct {
Name string `yaml:"name" doc:"name of the validator"`
Staked string `yaml:"staked" doc:"how much the validator has staked"`
Name string `yaml:"name" doc:"Name of the validator."`
Staked string `yaml:"staked" doc:"Amount staked by the validator."`
}
2 changes: 1 addition & 1 deletion ignite/config/chain/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func DefaultConfig() *Config {
type Config struct {
base.Config `yaml:",inline"`

Validators []Validator `yaml:"validators" doc:"holds info related to validator list settings"`
Validators []Validator `yaml:"validators" doc:"Contains information related to the list of validators and settings."`
}

func (c *Config) SetDefaults() error {
Expand Down
Loading

0 comments on commit 6f8df69

Please sign in to comment.