From f650bef328a2cf0ab7259f1bec2c639a9c8f77a8 Mon Sep 17 00:00:00 2001 From: Itay Levy Date: Wed, 2 Aug 2023 16:47:28 +0300 Subject: [PATCH 1/4] Added a relayer channel command --- cmd/relayer/channel/channel.go | 11 +++++++++++ cmd/relayer/relayer.go | 2 ++ 2 files changed, 13 insertions(+) create mode 100644 cmd/relayer/channel/channel.go diff --git a/cmd/relayer/channel/channel.go b/cmd/relayer/channel/channel.go new file mode 100644 index 00000000..4581ca26 --- /dev/null +++ b/cmd/relayer/channel/channel.go @@ -0,0 +1,11 @@ +package channel + +import "github.com/spf13/cobra" + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "channel", + Short: "Commands for managing the relayer channel", + } + return cmd +} diff --git a/cmd/relayer/relayer.go b/cmd/relayer/relayer.go index 5db4c7fe..078d326c 100644 --- a/cmd/relayer/relayer.go +++ b/cmd/relayer/relayer.go @@ -1,6 +1,7 @@ package relayer import ( + "github.com/dymensionxyz/roller/cmd/relayer/channel" start "github.com/dymensionxyz/roller/cmd/relayer/start" "github.com/spf13/cobra" ) @@ -11,5 +12,6 @@ func Cmd() *cobra.Command { Short: "Commands for running and managing the RollApp relayer.", } cmd.AddCommand(start.Start()) + cmd.AddCommand(channel.Cmd()) return cmd } From 2d3be41d85ce9bd7d4ab2e103b6c1718ddf90814 Mon Sep 17 00:00:00 2001 From: Itay Levy Date: Wed, 2 Aug 2023 16:50:20 +0300 Subject: [PATCH 2/4] Created command structure --- cmd/relayer/channel/channel.go | 6 +++++- cmd/relayer/channel/show/show.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 cmd/relayer/channel/show/show.go diff --git a/cmd/relayer/channel/channel.go b/cmd/relayer/channel/channel.go index 4581ca26..eb32e9d6 100644 --- a/cmd/relayer/channel/channel.go +++ b/cmd/relayer/channel/channel.go @@ -1,11 +1,15 @@ package channel -import "github.com/spf13/cobra" +import ( + "github.com/dymensionxyz/roller/cmd/relayer/channel/show" + "github.com/spf13/cobra" +) func Cmd() *cobra.Command { cmd := &cobra.Command{ Use: "channel", Short: "Commands for managing the relayer channel", } + cmd.AddCommand(show.Cmd()) return cmd } diff --git a/cmd/relayer/channel/show/show.go b/cmd/relayer/channel/show/show.go new file mode 100644 index 00000000..ab2653b3 --- /dev/null +++ b/cmd/relayer/channel/show/show.go @@ -0,0 +1,17 @@ +package show + +import ( + "fmt" + "github.com/spf13/cobra" +) + +func Cmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "show", + Short: "Show the channel data of the relayer on the local machine.", + Run: func(cmd *cobra.Command, args []string) { + fmt.Println("show channel") + }, + } + return cmd +} From c3b23b50c9bb0069028fd4182a6cda8f6488a9e1 Mon Sep 17 00:00:00 2001 From: Itay Levy Date: Wed, 2 Aug 2023 16:55:22 +0300 Subject: [PATCH 3/4] Implemented roller channel show command --- cmd/relayer/channel/show/show.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmd/relayer/channel/show/show.go b/cmd/relayer/channel/show/show.go index ab2653b3..0af7d88b 100644 --- a/cmd/relayer/channel/show/show.go +++ b/cmd/relayer/channel/show/show.go @@ -2,6 +2,9 @@ package show import ( "fmt" + "github.com/dymensionxyz/roller/cmd/utils" + "github.com/dymensionxyz/roller/config" + "github.com/dymensionxyz/roller/relayer" "github.com/spf13/cobra" ) @@ -10,7 +13,18 @@ func Cmd() *cobra.Command { Use: "show", Short: "Show the channel data of the relayer on the local machine.", Run: func(cmd *cobra.Command, args []string) { - fmt.Println("show channel") + home := cmd.Flag(utils.FlagNames.Home).Value.String() + rollappConfig, err := config.LoadConfigFromTOML(home) + utils.PrettifyErrorIfExists(err) + rly := relayer.NewRelayer(rollappConfig.Home, rollappConfig.RollappID, rollappConfig.HubData.ID) + srcChannel, dstChannel, err := rly.LoadChannels() + utils.PrettifyErrorIfExists(err) + if srcChannel == "" { + fmt.Println("💈 No channel has been created for the relayer yet.") + } else { + fmt.Printf("💈 Relayer Channels: src, %s <-> %s, dst", + srcChannel, dstChannel) + } }, } return cmd From 1230804f7209e754355c5614f964b8e731689aeb Mon Sep 17 00:00:00 2001 From: Itay Levy Date: Wed, 2 Aug 2023 17:08:39 +0300 Subject: [PATCH 4/4] Added a newline --- cmd/relayer/channel/show/show.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/relayer/channel/show/show.go b/cmd/relayer/channel/show/show.go index 0af7d88b..c09ad1d1 100644 --- a/cmd/relayer/channel/show/show.go +++ b/cmd/relayer/channel/show/show.go @@ -22,7 +22,7 @@ func Cmd() *cobra.Command { if srcChannel == "" { fmt.Println("💈 No channel has been created for the relayer yet.") } else { - fmt.Printf("💈 Relayer Channels: src, %s <-> %s, dst", + fmt.Printf("💈 Relayer Channels: src, %s <-> %s, dst\n", srcChannel, dstChannel) } },