fix default account addr prefix (#472)

This commit is contained in:
huanglins 2020-08-25 20:16:31 +08:00 committed by GitHub
parent 98610e4999
commit b3c895d039
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -24,4 +24,11 @@ func TestSetBech32Prefixes(t *testing.T) {
require.Equal(t, Bech32PrefixValPub, config.GetBech32ValidatorPubPrefix())
require.Equal(t, Bech32PrefixConsAddr, config.GetBech32ConsensusAddrPrefix())
require.Equal(t, Bech32PrefixConsPub, config.GetBech32ConsensusPubPrefix())
require.Equal(t, sdk.GetConfig().GetBech32AccountAddrPrefix(), config.GetBech32AccountAddrPrefix())
require.Equal(t, sdk.GetConfig().GetBech32AccountPubPrefix(), config.GetBech32AccountPubPrefix())
require.Equal(t, sdk.GetConfig().GetBech32ValidatorAddrPrefix(), config.GetBech32ValidatorAddrPrefix())
require.Equal(t, sdk.GetConfig().GetBech32ValidatorPubPrefix(), config.GetBech32ValidatorPubPrefix())
require.Equal(t, sdk.GetConfig().GetBech32ConsensusAddrPrefix(), config.GetBech32ConsensusAddrPrefix())
require.Equal(t, sdk.GetConfig().GetBech32ConsensusPubPrefix(), config.GetBech32ConsensusPubPrefix())
}

View File

@ -12,7 +12,7 @@ import (
)
func accountToHex(addr string) (string, error) {
if strings.HasPrefix(addr, sdk.Bech32PrefixAccAddr) {
if strings.HasPrefix(addr, sdk.GetConfig().GetBech32AccountAddrPrefix()) {
// Check to see if address is Cosmos bech32 formatted
toAddr, err := sdk.AccAddressFromBech32(addr)
if err != nil {
@ -47,7 +47,7 @@ func formatKeyToHash(key string) string {
}
func cosmosAddressFromArg(addr string) (sdk.AccAddress, error) {
if strings.HasPrefix(addr, sdk.Bech32PrefixAccAddr) {
if strings.HasPrefix(addr, sdk.GetConfig().GetBech32AccountAddrPrefix()) {
// Check to see if address is Cosmos bech32 formatted
toAddr, err := sdk.AccAddressFromBech32(addr)
if err != nil {