-
Notifications
You must be signed in to change notification settings - Fork 77
/
setup.go
33 lines (28 loc) · 1.21 KB
/
setup.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package types
import (
"github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// SdkConfigSetup represents a method that allows to customize the given sdk.ParsingConfig.
// This should be used to set custom Bech32 addresses prefixes and other app-related configurations.
type SdkConfigSetup func(config Config, sdkConfig *sdk.Config)
// DefaultConfigSetup represents a handy implementation of SdkConfigSetup that simply setups the prefix
// inside the configuration
func DefaultConfigSetup(cfg Config, sdkConfig *sdk.Config) {
prefix := cfg.GetCosmosConfig().GetPrefix()
sdkConfig.SetBech32PrefixForAccount(
prefix,
prefix+sdk.PrefixPublic,
)
sdkConfig.SetBech32PrefixForValidator(
prefix+sdk.PrefixValidator+sdk.PrefixOperator,
prefix+sdk.PrefixValidator+sdk.PrefixOperator+sdk.PrefixPublic,
)
sdkConfig.SetBech32PrefixForConsensusNode(
prefix+sdk.PrefixValidator+sdk.PrefixConsensus,
prefix+sdk.PrefixValidator+sdk.PrefixConsensus+sdk.PrefixPublic,
)
}
// -----------------------------------------------------------------
// EncodingConfigBuilder represents a function that is used to return the proper encoding config.
type EncodingConfigBuilder func() params.EncodingConfig