Skip to content

Commit

Permalink
feat: Add a roller relayer channel show command (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItayLevyOfficial authored Aug 2, 2023
1 parent 6faff32 commit 1d8d7e6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/relayer/channel/channel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package channel

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
}
31 changes: 31 additions & 0 deletions cmd/relayer/channel/show/show.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package show

import (
"fmt"
"github.com/dymensionxyz/roller/cmd/utils"
"github.com/dymensionxyz/roller/config"
"github.com/dymensionxyz/roller/relayer"
"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) {
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\n",
srcChannel, dstChannel)
}
},
}
return cmd
}
2 changes: 2 additions & 0 deletions cmd/relayer/relayer.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand All @@ -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
}

0 comments on commit 1d8d7e6

Please sign in to comment.