Skip to content

Commit

Permalink
Register address prefix at app config
Browse files Browse the repository at this point in the history
  • Loading branch information
elise-ng committed Apr 4, 2022
1 parent 969e409 commit 38905c8
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ func RegisterDenoms() {
}
}

func SetAddressPrefixes() {
bech32PrefixesAccAddr := []string{"like", "cosmos"}
bech32PrefixesAccPub := make([]string, 0, len(bech32PrefixesAccAddr))
bech32PrefixesValAddr := make([]string, 0, len(bech32PrefixesAccAddr))
bech32PrefixesValPub := make([]string, 0, len(bech32PrefixesAccAddr))
bech32PrefixesConsAddr := make([]string, 0, len(bech32PrefixesAccAddr))
bech32PrefixesConsPub := make([]string, 0, len(bech32PrefixesAccAddr))

for _, prefix := range bech32PrefixesAccAddr {
bech32PrefixesAccPub = append(bech32PrefixesAccPub, prefix+"pub")
bech32PrefixesValAddr = append(bech32PrefixesValAddr, prefix+"valoper")
bech32PrefixesValPub = append(bech32PrefixesValPub, prefix+"valoperpub")
bech32PrefixesConsAddr = append(bech32PrefixesConsAddr, prefix+"valcons")
bech32PrefixesConsPub = append(bech32PrefixesConsPub, prefix+"valconspub")
}
config := sdk.GetConfig()
config.SetBech32PrefixesForAccount(bech32PrefixesAccAddr, bech32PrefixesAccPub)
config.SetBech32PrefixesForValidator(bech32PrefixesValAddr, bech32PrefixesValPub)
config.SetBech32PrefixesForConsensusNode(bech32PrefixesConsAddr, bech32PrefixesConsPub)
}

type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Codec
Expand All @@ -54,5 +75,6 @@ func MakeEncodingConfig() EncodingConfig {
}

func init() {
SetAddressPrefixes()
RegisterDenoms()
}

0 comments on commit 38905c8

Please sign in to comment.