-
Notifications
You must be signed in to change notification settings - Fork 1
/
submitSelletFeedBack.go
executable file
·49 lines (39 loc) · 1.39 KB
/
submitSelletFeedBack.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 cli
import (
"github.com/cosmos/cosmos-sdk/client/context"
cTypes "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/commitHub/commitBlockchain/codec"
"github.com/commitHub/commitBlockchain/types"
"github.com/commitHub/commitBlockchain/modules/auth"
"github.com/commitHub/commitBlockchain/modules/auth/client/utils"
types2 "github.com/commitHub/commitBlockchain/modules/reputation/internal/types"
)
func SubmitSellerFeedbackCmd(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "sellerFeedback",
Short: "seller gives feedback to the buyer",
RunE: func(cmd *cobra.Command, args []string) error {
txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
cliCtx := context.NewCLIContext().WithCodec(cdc)
to := viper.GetString(FlagTo)
toAddress, err := cTypes.AccAddressFromBech32(to)
if err != nil {
return err
}
pegHashStr := viper.GetString(FlagPegHash)
pegHashHex, err := types.GetAssetPegHashHex(pegHashStr)
if err != nil {
return err
}
rating := viper.GetInt64(FlagRating)
msg := types2.BuildSellerFeedbackMsg(toAddress, cliCtx.GetFromAddress(), pegHashHex, rating)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []cTypes.Msg{msg})
},
}
cmd.Flags().AddFlagSet(fsPeghash)
cmd.Flags().AddFlagSet(fsRating)
cmd.Flags().AddFlagSet(fsTo)
return cmd
}