Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a roller relayer channel show command #352

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}