-
Notifications
You must be signed in to change notification settings - Fork 230
/
types.go
34 lines (28 loc) · 907 Bytes
/
types.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
package types
import (
"math/big"
"strings"
)
var (
Ten = big.NewInt(10)
TenPowTen = Ten.Exp(Ten, Ten, nil)
)
const (
ibcDenomPrefix = "ibc/"
ibcDenomLen = len(ibcDenomPrefix) + 64
gravityDenomPrefix = "gravity0x"
gravityDenomLen = len(gravityDenomPrefix) + 40
)
// IsValidIBCDenom returns if denom is a valid ibc denom
func IsValidIBCDenom(denom string) bool {
return len(denom) == ibcDenomLen && strings.HasPrefix(denom, ibcDenomPrefix)
}
// IsValidGravityDenom returns if denom is a valid gravity denom
func IsValidGravityDenom(denom string) bool {
return len(denom) == gravityDenomLen && strings.HasPrefix(denom, gravityDenomPrefix)
}
// IsValidDenomToWrap returns if it's ok to wrap the native denom in erc20
// Currently only supports ibc and gravity denom
func IsValidDenomToWrap(denom string) bool {
return IsValidIBCDenom(denom) || IsValidGravityDenom(denom)
}