-
Notifications
You must be signed in to change notification settings - Fork 251
/
tx.go
59 lines (50 loc) · 1.62 KB
/
tx.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
57
58
59
package client
import (
"fmt"
"github.com/celestiaorg/celestia-app/x/qgb/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/spf13/cobra"
)
// GetTxCmd returns the transaction commands for this module
func GetTxCmd() *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
DisableFlagParsing: true,
SuggestionsMinimumDistance: 2,
RunE: client.ValidateCmd,
}
cmd.AddCommand(CmdRegisterEVMAddress())
return cmd
}
func CmdRegisterEVMAddress() *cobra.Command {
cmd := &cobra.Command{
Use: "register [valAddress] [evmAddress]",
Short: "Register an EVM address for a validator",
Long: `Registers an EVM address for a validator. This address will be used to
sign attestations as part of the QGB protocol. Only the validator, as the signer,
can register an EVM address. To change the EVM address, the validator can simply
send a new message overriding the previous one.
`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
valAddress, evmAddress := args[0], args[1]
msg := &types.MsgRegisterEVMAddress{
ValidatorAddress: valAddress,
EvmAddress: evmAddress,
}
if err := msg.ValidateBasic(); err != nil {
return err
}
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
flags.AddTxFlagsToCmd(cmd)
return cmd
}