-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
43 lines (35 loc) · 914 Bytes
/
config.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
package v1
import (
"github.com/pelletier/go-toml"
)
type TomlConfig struct {
PricefeedConfig *PricefeedConfig `toml:"pricefeed"`
DistributionConfig *DistributionConfig `toml:"distribution"`
}
func ParseConfig(bz []byte) (TomlConfig, error) {
var tomlCfg TomlConfig
err := toml.Unmarshal(bz, &tomlCfg)
if err != nil {
return TomlConfig{}, err
}
return TomlConfig{
PricefeedConfig: tomlCfg.PricefeedConfig,
DistributionConfig: tomlCfg.DistributionConfig,
}, nil
}
type PricefeedConfig struct {
Tokens []Token `toml:"tokens"`
}
type Token struct {
Name string `toml:"name"`
Units []TokenUnit `toml:"units"`
}
type TokenUnit struct {
Denom string `toml:"denom"`
Exponent int `toml:"exponent"`
Aliases []string `toml:"aliases"`
PriceID string `toml:"price_id"`
}
type DistributionConfig struct {
DistributionFrequency int64 `toml:"distribution_frequency"`
}