/
env.go
73 lines (58 loc) · 2.31 KB
/
env.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package types
const (
// prefixChain defines the prefix of this chain
prefixChain = "i"
// PrefixAcc is the prefix for account
prefixAccount = "a"
// prefixValidator is the prefix for validator keys
prefixValidator = "v"
// prefixConsensus is the prefix for consensus keys
prefixConsensus = "c"
// prefixPublic is the prefix for public
prefixPublic = "p"
// prefixAddress is the prefix for address
prefixAddress = "a"
)
var (
prefixCfg = &AddrPrefixCfg{
bech32AddressPrefix: map[string]string{
"account_addr": prefixChain + prefixAccount + prefixAddress,
"validator_addr": prefixChain + prefixValidator + prefixAddress,
"consensus_addr": prefixChain + prefixConsensus + prefixAddress,
"account_pub": prefixChain + prefixAccount + prefixPublic,
"validator_pub": prefixChain + prefixValidator + prefixPublic,
"consensus_pub": prefixChain + prefixConsensus + prefixPublic,
},
}
)
type AddrPrefixCfg struct {
bech32AddressPrefix map[string]string
}
// GetAddrPrefixCfg returns the config instance for the corresponding Network type
func GetAddrPrefixCfg() *AddrPrefixCfg {
return prefixCfg
}
// GetBech32AccountAddrPrefix returns the Bech32 prefix for account address
func (config *AddrPrefixCfg) GetBech32AccountAddrPrefix() string {
return config.bech32AddressPrefix["account_addr"]
}
// GetBech32ValidatorAddrPrefix returns the Bech32 prefix for validator address
func (config *AddrPrefixCfg) GetBech32ValidatorAddrPrefix() string {
return config.bech32AddressPrefix["validator_addr"]
}
// GetBech32ConsensusAddrPrefix returns the Bech32 prefix for consensus node address
func (config *AddrPrefixCfg) GetBech32ConsensusAddrPrefix() string {
return config.bech32AddressPrefix["consensus_addr"]
}
// GetBech32AccountPubPrefix returns the Bech32 prefix for account public key
func (config *AddrPrefixCfg) GetBech32AccountPubPrefix() string {
return config.bech32AddressPrefix["account_pub"]
}
// GetBech32ValidatorPubPrefix returns the Bech32 prefix for validator public key
func (config *AddrPrefixCfg) GetBech32ValidatorPubPrefix() string {
return config.bech32AddressPrefix["validator_pub"]
}
// GetBech32ConsensusPubPrefix returns the Bech32 prefix for consensus node public key
func (config *AddrPrefixCfg) GetBech32ConsensusPubPrefix() string {
return config.bech32AddressPrefix["consensus_pub"]
}