-
Notifications
You must be signed in to change notification settings - Fork 1
/
issueFiat.go
executable file
·49 lines (39 loc) · 1.45 KB
/
issueFiat.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/types"
"github.com/commitHub/commitBlockchain/codec"
"github.com/commitHub/commitBlockchain/modules/auth"
"github.com/commitHub/commitBlockchain/modules/auth/client/utils"
"github.com/commitHub/commitBlockchain/modules/bank/client"
)
func IssueFiatCmd(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: "issueFiat",
Short: "Initializes fiat with the given details and issues to the given address",
RunE: func(cmd *cobra.Command, args []string) error {
txBldr := auth.NewTxBuilderFromCLI().WithTxEncoder(utils.GetTxEncoder(cdc))
cliCtx := context.NewCLIContext().WithCodec(cdc)
toStr := viper.GetString(FlagTo)
to, err := cTypes.AccAddressFromBech32(toStr)
if err != nil {
return nil
}
transactionIDStr := viper.GetString(FlagTransactionID)
transactionAmountInt64 := viper.GetInt64(FlagTransactionAmount)
fiatPeg := &types.BaseFiatPeg{
TransactionID: transactionIDStr,
TransactionAmount: transactionAmountInt64,
}
msg := client.BuildIssueFiatMsg(cliCtx.GetFromAddress(), to, fiatPeg)
return utils.GenerateOrBroadcastMsgs(cliCtx, txBldr, []cTypes.Msg{msg})
},
}
cmd.Flags().AddFlagSet(fsTo)
cmd.Flags().AddFlagSet(fsTransactionID)
cmd.Flags().AddFlagSet(fsTransactionAmount)
return cmd
}