-
Notifications
You must be signed in to change notification settings - Fork 169
/
denom.go
42 lines (34 loc) · 851 Bytes
/
denom.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
package types
import (
"strings"
"gopkg.in/yaml.v3"
)
// String implements fmt.Stringer interface
func (d Denom) String() string {
out, _ := yaml.Marshal(d)
return string(out)
}
// Equal implements equal interface
func (d Denom) Equal(d1 *Denom) bool {
return d.BaseDenom == d1.BaseDenom &&
d.SymbolDenom == d1.SymbolDenom &&
d.Exponent == d1.Exponent
}
// DenomList is array of Denom
type DenomList []Denom
// String implements fmt.Stringer interface
func (dl DenomList) String() (out string) {
for _, d := range dl {
out += d.String() + "\n"
}
return strings.TrimSpace(out)
}
// Contains checks whether or not a SymbolDenom (e.g. UMEE) is in the DenomList
func (dl DenomList) Contains(symbolDenom string) bool {
for _, d := range dl {
if strings.EqualFold(d.SymbolDenom, symbolDenom) {
return true
}
}
return false
}