-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli_helpers.go
49 lines (41 loc) · 1.15 KB
/
cli_helpers.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
package osmoutils
import (
"fmt"
"strconv"
"strings"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/testutil/network"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func DefaultFeeString(cfg network.Config) string {
feeCoins := sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, sdk.NewInt(10)))
return fmt.Sprintf("--%s=%s", flags.FlagFees, feeCoins.String())
}
const (
base = 10
bitlen = 64
)
func ParseUint64SliceFromString(s string, separator string) ([]uint64, error) {
var parsedInts []uint64
for _, s := range strings.Split(s, separator) {
s = strings.TrimSpace(s)
parsed, err := strconv.ParseUint(s, base, bitlen)
if err != nil {
return []uint64{}, err
}
parsedInts = append(parsedInts, parsed)
}
return parsedInts, nil
}
func ParseSdkIntFromString(s string, separator string) ([]sdk.Int, error) {
var parsedInts []sdk.Int
for _, weightStr := range strings.Split(s, separator) {
weightStr = strings.TrimSpace(weightStr)
parsed, err := strconv.ParseUint(weightStr, base, bitlen)
if err != nil {
return parsedInts, err
}
parsedInts = append(parsedInts, sdk.NewIntFromUint64(parsed))
}
return parsedInts, nil
}