- 
                Notifications
    You must be signed in to change notification settings 
- Fork 570
feat(chainconfig): implementation of the migration system #2512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
19f5106
              fd2df4f
              a888e94
              9cf765d
              9fd917b
              ed10e84
              406892b
              0d55203
              efd4cdd
              ea5eb64
              6b0a64a
              4d32b91
              de14518
              d226a4d
              8e95f25
              075ca49
              a0d5b67
              e04345d
              03501b3
              459091b
              e3b0326
              7255760
              16f2a86
              1c59b08
              bfe0781
              3c2540f
              482c7b0
              3ab4c60
              9669aab
              953e8e7
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| package common | ||
|  | ||
| type Version int | ||
|  | ||
| // Account holds the options related to setting up Cosmos wallets. | ||
| type Account struct { | ||
| Name string `yaml:"name"` | ||
| Coins []string `yaml:"coins,omitempty"` | ||
| Mnemonic string `yaml:"mnemonic,omitempty"` | ||
| Address string `yaml:"address,omitempty"` | ||
| CoinType string `yaml:"cointype,omitempty"` | ||
|  | ||
| // The RPCAddress off the chain that account is issued at. | ||
| RPCAddress string `yaml:"rpc_address,omitempty"` | ||
| } | ||
|  | ||
| // Build holds build configs. | ||
| type Build struct { | ||
| Main string `yaml:"main"` | ||
| Binary string `yaml:"binary"` | ||
| LDFlags []string `yaml:"ldflags"` | ||
| Proto Proto `yaml:"proto"` | ||
| } | ||
|  | ||
| // 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"` | ||
|  | ||
| // 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"` | ||
| } | ||
|  | ||
| // Client configures code generation for clients. | ||
| type Client struct { | ||
| // Vuex configures code generation for Vuex. | ||
| Vuex Vuex `yaml:"vuex"` | ||
|  | ||
| // Dart configures client code generation for Dart. | ||
| Dart Dart `yaml:"dart"` | ||
|  | ||
| // OpenAPI configures OpenAPI spec generation for API. | ||
| OpenAPI OpenAPI `yaml:"openapi"` | ||
| } | ||
|  | ||
| // Vuex configures code generation for Vuex. | ||
| type Vuex struct { | ||
| // Path configures out location for generated Vuex code. | ||
| Path string `yaml:"path"` | ||
| } | ||
|  | ||
| // Dart configures client code generation for Dart. | ||
| type Dart struct { | ||
| // Path configures out location for generated Dart code. | ||
| Path string `yaml:"path"` | ||
| } | ||
|  | ||
| // OpenAPI configures OpenAPI spec generation for API. | ||
| type OpenAPI struct { | ||
| Path string `yaml:"path"` | ||
| } | ||
|  | ||
| // Faucet configuration. | ||
| type Faucet struct { | ||
| // Name is faucet account's name. | ||
| Name *string `yaml:"name"` | ||
|  | ||
| // Coins holds type of coin denoms and amounts to distribute. | ||
| Coins []string `yaml:"coins"` | ||
|  | ||
| // CoinsMax holds of chain denoms and their max amounts that can be transferred | ||
| // to single user. | ||
| CoinsMax []string `yaml:"coins_max"` | ||
|  | ||
| // LimitRefreshTime sets the timeframe at the end of which the limit will be refreshed | ||
| RateLimitWindow string `yaml:"rate_limit_window"` | ||
|  | ||
| // Host is the host of the faucet server | ||
| Host string `yaml:"host"` | ||
|  | ||
| // Port number for faucet server to listen at. | ||
| Port int `yaml:"port"` | ||
| } | ||
|  | ||
| // Init overwrites sdk configurations with given values. | ||
| type Init struct { | ||
| // App overwrites appd's config/app.toml configs. | ||
| App map[string]interface{} `yaml:"app"` | ||
|  | ||
| // Client overwrites appd's config/client.toml configs. | ||
| Client map[string]interface{} `yaml:"client"` | ||
|  | ||
| // Config overwrites appd's config/config.toml configs. | ||
| Config map[string]interface{} `yaml:"config"` | ||
|  | ||
| // Home overwrites default home directory used for the app | ||
| Home string `yaml:"home"` | ||
|  | ||
| // KeyringBackend is the default keyring backend to use for blockchain initialization | ||
| KeyringBackend string `yaml:"keyring-backend"` | ||
| } | ||
|  | ||
| // Host keeps configuration related to started servers. | ||
| type Host struct { | ||
| RPC string `yaml:"rpc"` | ||
| P2P string `yaml:"p2p"` | ||
| Prof string `yaml:"prof"` | ||
| GRPC string `yaml:"grpc"` | ||
| GRPCWeb string `yaml:"grpc-web"` | ||
| API string `yaml:"api"` | ||
| } | ||
|  | ||
| // BaseConfig is the struct containing all the common fields for the config across all the versions. | ||
| type BaseConfig struct { | ||
| ConfigVersion Version `yaml:"version"` | ||
| Build Build `yaml:"build"` | ||
| Accounts []Account `yaml:"accounts"` | ||
| Faucet Faucet `yaml:"faucet"` | ||
| Client Client `yaml:"client"` | ||
| Genesis map[string]interface{} `yaml:"genesis"` | ||
| } | ||
|  | ||
| // GetVersion returns the version of the config.yaml file. | ||
| func (c BaseConfig) Version() Version { | ||
| return c.ConfigVersion | ||
| } | ||
|  | ||
| // AccountByName finds account by name. | ||
| func (c BaseConfig) AccountByName(name string) (acc Account, found bool) { | ||
| for _, acc := range c.Accounts { | ||
| if acc.Name == name { | ||
| return acc, true | ||
| } | ||
| } | ||
| return Account{}, false | ||
| } | 
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||
| package common | ||||
|  | ||||
| // Config is the interface defining all the common methods for the ConfigYaml struct across all supported versions | ||||
| type Config interface { | ||||
| Clone() Config | ||||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 
        Suggested change
       
 Why do we need Clone()? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Every time we retrieve the instance based on the version, but we need to keep the original in the map without any changes. That's why we only return a copy, so we just leverage the copy to parse, and nothing is changed in the map. | ||||
|  | ||||
| // Version returns the version of the Config | ||||
| Version() Version | ||||
|  | ||||
| // ConvertNext converts the instance of Config from the current version to the next version. | ||||
| ConvertNext() (Config, error) | ||||
| } | ||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this to the
chainconfigand remove this file?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving into chainconfig can lead to the error "import cycle not allowed". That was the reason I created this interface in common package to avoid it.