forked from forbole/juno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdk.go
35 lines (29 loc) · 1.24 KB
/
sdk.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
34
35
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/gotabit/gotabit/app/params"
"github.com/gotabit/juno/v5/types/config"
)
// SdkConfigSetup represents a method that allows to customize the given sdk.Config.
// This should be used to set custom Bech32 addresses prefixes and other app-related configurations.
type SdkConfigSetup func(config config.Config, sdkConfig *sdk.Config)
// DefaultConfigSetup represents a handy implementation of SdkConfigSetup that simply setups the prefix
// inside the configuration
func DefaultConfigSetup(cfg config.Config, sdkConfig *sdk.Config) {
prefix := cfg.Chain.Bech32Prefix
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