bridge: add "debug decode-vaa"
This commit is contained in:
parent
f36ecc34f7
commit
04e3ad772a
|
@ -0,0 +1,40 @@
|
|||
package debug
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"github.com/certusone/wormhole/bridge/pkg/vaa"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/spf13/cobra"
|
||||
"log"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var DebugCmd = &cobra.Command{
|
||||
Use: "debug",
|
||||
Short: "Debugging utilities",
|
||||
}
|
||||
|
||||
var decodeVaaCmd = &cobra.Command{
|
||||
Use: "decode-vaa [DATA]",
|
||||
Short: "Decode a hex-encoded VAA",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
for _, arg := range args {
|
||||
arg = strings.TrimPrefix(arg, "0x")
|
||||
b, err := hex.DecodeString(arg)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
v, err := vaa.Unmarshal(b)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
spew.Dump(v)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
DebugCmd.AddCommand(decodeVaaCmd)
|
||||
}
|
|
@ -2,6 +2,7 @@ package cmd
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/certusone/wormhole/bridge/cmd/debug"
|
||||
"github.com/certusone/wormhole/bridge/pkg/version"
|
||||
"os"
|
||||
|
||||
|
@ -48,6 +49,7 @@ func init() {
|
|||
rootCmd.AddCommand(guardiand.AdminCmd)
|
||||
rootCmd.AddCommand(guardiand.TemplateCmd)
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
rootCmd.AddCommand(debug.DebugCmd)
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
|
|
Loading…
Reference in New Issue