Repository: desmos-labs/desmos (go)
Issue: Make the name of ChainConfig case insensitive
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺ 
v                            ✰  Thanks for opening an issue! ✰    
v    Before smashing the submit button please review the template.
v    Word of caution: poorly thought-out proposals may be rejected 
v                     without deliberation 
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  --> 

## Feature description 
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
Currently, the name of the chain config is not In `x/profile` is not specified to use lower case. 
This means that currently it's possible to have many chain configs with very similar chain name, say:

* Cosmos
* cosmos
* cosMos
* ...  

This might be a problem in the future due to the possible impersonification.

## Implementation proposal
<!-- A clear and concise description of what you would want to happen. -->

To solve it, we can convert the name to lower case in the constructor and make sure it is all in lower case by Validate().
```golang
// NewChainConfig allows to build a new ChainConfig instance
func NewChainConfig(name string) ChainConfig {
	return ChainConfig{
		Name: strings.ToLower(name),
	}
}

// Validate checks the validity of the ChainConfig
func (c ChainConfig) Validate() error {
	if strings.TrimSpace(c.Name) == "" {
		return fmt.Errorf("chain name cannot be empty or blank")
	}
	if strings.ToLower(c.Name) != c.Name {
	        return fmt.Errorof("chain name should be lower case")
	}
	return nil
}
```

What do you think? @RiccardoM @bragaz 
Pull request description: Case insensitive chain name
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v                               ✰  Thanks for creating a PR! ✰    
v    Before smashing the submit button please review the checkboxes.
v    If a checkbox is n/a - please still include it but + a little note why
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Description
<!-- Small description -->

This PR makes the name of `ChainConfig` case insensitive.
Closes #526

## Checklist
- [x] Targeted PR against correct branch.
- [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Wrote unit tests.
- [ ] Wrote integration tests (simulation & CLI). 
- [ ] Updated the documentation. 
- [ ] Added an entry to the `CHANGELOG.md` file.
- [ ] Re-reviewed `Files changed` in the Github PR explorer.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index eb6422dd..40a42f63 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,6 @@
+# Unreleased
+- Require chain name to be lowercase ([#533](https://github.com/desmos-labs/desmos/pull/533))
+
 # Version 0.17.0
 ## Changes
 - Added the new `x/subspaces` module ([#392](https://github.com/desmos-labs/desmos/issues/392))
diff --git a/x/profiles/types/models_chain_links.go b/x/profiles/types/models_chain_links.go
index c40e9a6b..ac15106b 100644
--- a/x/profiles/types/models_chain_links.go
+++ b/x/profiles/types/models_chain_links.go
@@ -31,6 +31,9 @@ func (c ChainConfig) Validate() error {
 	if strings.TrimSpace(c.Name) == "" {
 		return fmt.Errorf("chain name cannot be empty or blank")
 	}
+	if c.Name != strings.ToLower(c.Name) {
+		return fmt.Errorf("chain name must be lowercase")
+	}
 	return nil
 }
 


Test patch:
diff --git a/x/profiles/types/models_chain_links_test.go b/x/profiles/types/models_chain_links_test.go
index 64be3aa7..70678b07 100644
--- a/x/profiles/types/models_chain_links_test.go
+++ b/x/profiles/types/models_chain_links_test.go
@@ -39,6 +39,11 @@ func TestChainConfig_Validate(t *testing.T) {
 			chainConfig: types.NewChainConfig("    "),
 			shouldErr:   true,
 		},
+		{
+			name:        "uppercase chain name returns error",
+			chainConfig: types.NewChainConfig("TC"),
+			shouldErr:   true,
+		},
 		{
 			name:        "correct chain config returns no error",
 			chainConfig: types.NewChainConfig("tc"),