-
Notifications
You must be signed in to change notification settings - Fork 28
/
moduleaccounts.go
30 lines (26 loc) · 1.01 KB
/
moduleaccounts.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
package tmcosmosutils
import "crypto/sha256"
type ModuleAccounts struct {
FeeCollector string
Mint string
Distribution string
Gov string
BondedTokensPool string
NotBondedTokensPool string
IBCTransfer string
}
func NewModuleAccounts(addressPrefix string) ModuleAccounts {
return ModuleAccounts{
FeeCollector: getModuleAccount(addressPrefix, "fee_collector"),
Mint: getModuleAccount(addressPrefix, "mint"),
Distribution: getModuleAccount(addressPrefix, "distribution"),
Gov: getModuleAccount(addressPrefix, "gov"),
BondedTokensPool: getModuleAccount(addressPrefix, "bonded_tokens_pool"),
NotBondedTokensPool: getModuleAccount(addressPrefix, "not_bonded_tokens_pool"),
IBCTransfer: getModuleAccount(addressPrefix, "transfer"),
}
}
func getModuleAccount(addressPrefix string, module string) string {
b := sha256.Sum256([]byte(module))
return MustModuleAccountFromBytes(addressPrefix, b[:20])
}