-
Notifications
You must be signed in to change notification settings - Fork 55
/
cli_helpers.go
76 lines (56 loc) 路 2.26 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package testutil
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/testutil"
clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
sdk "github.com/cosmos/cosmos-sdk/types"
bankcli "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
"github.com/crescent-network/crescent/x/farming/client/cli"
)
var commonArgs = []string{
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()),
}
// MsgCreateFixedAmountPlanExec creates a transaction for creating a private fixed amount plan.
func MsgCreateFixedAmountPlanExec(clientCtx client.Context, from string, file string,
extraArgs ...string) (testutil.BufferWriter, error) {
args := append([]string{
file,
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
}, commonArgs...)
args = append(args, commonArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, cli.NewCreateFixedAmountPlanCmd(), args)
}
// MsgStakeExec creates a transaction for staking coin.
func MsgStakeExec(clientCtx client.Context, from string, stakingCoins string,
extraArgs ...string) (testutil.BufferWriter, error) {
args := append([]string{
stakingCoins,
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
}, commonArgs...)
args = append(args, commonArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, cli.NewStakeCmd(), args)
}
// MsgAdvanceEpochExec creates a transaction to advance epoch by 1.
func MsgAdvanceEpochExec(clientCtx client.Context, from string,
extraArgs ...string) (testutil.BufferWriter, error) {
args := append([]string{
fmt.Sprintf("--%s=%s", flags.FlagFrom, from),
}, commonArgs...)
args = append(args, commonArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, cli.NewAdvanceEpochCmd(), args)
}
// MsgSendExec creates a transaction to transfer coins.
func MsgSendExec(clientCtx client.Context, from string, to string, amount string,
extraArgs ...string) (testutil.BufferWriter, error) {
args := append([]string{
from,
to,
amount,
}, commonArgs...)
args = append(args, commonArgs...)
return clitestutil.ExecTestCLICmd(clientCtx, bankcli.NewSendTxCmd(), args)
}