mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-09-13 20:00:10 +00:00

* change: CreateRedeemClaim consumes entire claim for reduced complexity --------- Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
81 lines
1.8 KiB
Go
81 lines
1.8 KiB
Go
package cli
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/cosmos/cosmos-sdk/client"
|
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
|
"github.com/cosmos/cosmos-sdk/client/tx"
|
|
"github.com/planetmint/planetmint-go/x/dao/types"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func CmdCreateRedeemClaim() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "create-redeem-claim [beneficiary] [amount]",
|
|
Short: "Create a new redeem-claim",
|
|
Args: cobra.ExactArgs(4),
|
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
|
// Get indexes
|
|
indexBeneficiary := args[0]
|
|
|
|
clientCtx, err := client.GetClientTxContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
msg := types.NewMsgCreateRedeemClaim(
|
|
clientCtx.GetFromAddress().String(),
|
|
indexBeneficiary,
|
|
)
|
|
if err := msg.ValidateBasic(); err != nil {
|
|
return err
|
|
}
|
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
|
},
|
|
}
|
|
|
|
flags.AddTxFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|
|
|
|
func CmdUpdateRedeemClaim() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "update-redeem-claim [beneficiary] [id] [liquid-tx-hash]",
|
|
Short: "Update a redeem-claim",
|
|
Args: cobra.ExactArgs(4),
|
|
RunE: func(cmd *cobra.Command, args []string) (err error) {
|
|
// Get indexes
|
|
indexBeneficiary := args[0]
|
|
indexID, err := strconv.ParseUint(args[1], 10, 64)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Get value arguments
|
|
argLiquidTxHash := args[2]
|
|
|
|
clientCtx, err := client.GetClientTxContext(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
msg := types.NewMsgUpdateRedeemClaim(
|
|
clientCtx.GetFromAddress().String(),
|
|
indexBeneficiary,
|
|
argLiquidTxHash,
|
|
indexID,
|
|
)
|
|
if err := msg.ValidateBasic(); err != nil {
|
|
return err
|
|
}
|
|
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
|
},
|
|
}
|
|
|
|
flags.AddTxFlagsToCmd(cmd)
|
|
|
|
return cmd
|
|
}
|