-
Notifications
You must be signed in to change notification settings - Fork 0
/
tx_deposit.go
56 lines (44 loc) · 1.31 KB
/
tx_deposit.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
package cli
import (
"fmt"
"strings"
"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/cosmos/cosmos-sdk/version"
"github.com/furychain/fury/x/house/types"
"github.com/spf13/cobra"
)
func CmdDeposit() *cobra.Command {
cmd := &cobra.Command{
Use: "deposit [market_uid] [amount] [ticket]",
Args: cobra.ExactArgs(3),
Short: "Deposit tokens in a market order book to be the house",
Long: strings.TrimSpace(
fmt.Sprintf(`Deposit tokens in a market order book to be the house.
Example:
$ %s tx house deposit bc79a72c-ad7e-4cf5-91a2-98af2751e812 1000ufury {ticket string} --from mykey
`,
version.AppName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
argMarketUID := args[0]
argAmountCosmosInt, ok := sdk.NewIntFromString(args[1])
if !ok {
return types.ErrInvalidAmount
}
argTicket := args[2]
depAddr := clientCtx.GetFromAddress()
msg := types.NewMsgDeposit(depAddr.String(), argMarketUID, argAmountCosmosInt, argTicket)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}