-
Notifications
You must be signed in to change notification settings - Fork 48
/
tx_bond.go
44 lines (37 loc) · 972 Bytes
/
tx_bond.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
package cli
import (
"fmt"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/elys-network/elys/x/stablestake/types"
"github.com/spf13/cobra"
)
func CmdBond() *cobra.Command {
cmd := &cobra.Command{
Use: "bond [amount]",
Short: "Broadcast message bond",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
amount, ok := sdk.NewIntFromString(args[0])
if !ok {
return fmt.Errorf("unable to parse bonding amount")
}
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
msg := types.NewMsgBond(
clientCtx.GetFromAddress().String(),
amount,
)
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}