Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Move sign and verify to a message subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
pscott31 authored and ValentinTrinque committed Dec 23, 2021
1 parent 3d47a1c commit 81e6ec5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- [446](https://github.com/vegaprotocol/vegawallet/pull/446) - Field `mnemonic` in HTTP response for wallet creation has been removed in favor of `recoveryPhrase`
- [446](https://github.com/vegaprotocol/vegawallet/pull/446) - Field `mnemonic` in HTTP request for wallet import has been removed in favor of `recoveryPhrase`
- [446](https://github.com/vegaprotocol/vegawallet/pull/446) - The key printed on the JSON output for the `key generate` command is now at the root of the response, just like the output of the `key describe` command.
- [450](https://github.com/vegaprotocol/vegawallet/pull/450) - Move `sign` and `verify` commands to a a `message` subcommand, e.g. `message sign` and `message verify`

### 🗑️ Deprecation
- [](https://github.com/vegaprotocol/vegawallet/pull/) -
Expand Down
19 changes: 19 additions & 0 deletions cmd/message.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package cmd

import (
"io"

"github.com/spf13/cobra"
)

func NewCmdMessage(w io.Writer, rf *RootFlags) *cobra.Command {
cmd := &cobra.Command{
Use: "message",
Short: "Sign and verify messages",
Long: "Sign and verify messages",
}

cmd.AddCommand(NewCmdSignMessage(w, rf))
cmd.AddCommand(NewCmdVerifyMessage(w, rf))
return cmd
}
2 changes: 1 addition & 1 deletion cmd/sign.go → cmd/message_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (

signMessageExample = cli.Examples(`
# Sign a message
vegawallet sign --message MESSAGE --wallet WALLET --pubkey PUBKEY
vegawallet message sign --message MESSAGE --wallet WALLET --pubkey PUBKEY
`)
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/verify.go → cmd/message_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (

verifyMessageExample = cli.Examples(`
# Verify the signature of a message
vegawallet verify --message MESSAGE --signature SIGNATURE --pubkey PUBKEY
vegawallet message verify --message MESSAGE --signature SIGNATURE --pubkey PUBKEY
`)
)

Expand Down
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ func BuildCmdRoot(w io.Writer, vh CheckVersionHandler) *cobra.Command {
// Root commands
cmd.AddCommand(NewCmdInit(w, f))
cmd.AddCommand(NewCmdCompletion(w))
cmd.AddCommand(NewCmdSignMessage(w, f))
cmd.AddCommand(NewCmdVerifyMessage(w, f))
cmd.AddCommand(NewCmdVersion(w, f))

// Sub-commands
Expand All @@ -128,6 +126,7 @@ func BuildCmdRoot(w io.Writer, vh CheckVersionHandler) *cobra.Command {
cmd.AddCommand(NewCmdNetwork(w, f))
cmd.AddCommand(NewCmdService(w, f))
cmd.AddCommand(NewCmdTx(w, f))
cmd.AddCommand(NewCmdMessage(w, f))

// Wallet commands
// We don't have a wrapper sub-command for wallet commands.
Expand Down
4 changes: 2 additions & 2 deletions tests/commands_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ type SignMessageResponse struct {

func SignMessage(t *testing.T, args []string) (*SignMessageResponse, error) {
t.Helper()
argsWithCmd := []string{"sign"}
argsWithCmd := []string{"message", "sign"}
argsWithCmd = append(argsWithCmd, args...)
output, err := ExecuteCmd(t, argsWithCmd)
if err != nil {
Expand Down Expand Up @@ -655,7 +655,7 @@ type VerifyMessageResponse struct {

func VerifyMessage(t *testing.T, args []string) (*VerifyMessageResponse, error) {
t.Helper()
argsWithCmd := []string{"verify"}
argsWithCmd := []string{"message", "verify"}
argsWithCmd = append(argsWithCmd, args...)
output, err := ExecuteCmd(t, argsWithCmd)
if err != nil {
Expand Down

0 comments on commit 81e6ec5

Please sign in to comment.