Skip to content

Commit

Permalink
fix: relayer ibc creation (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
artemijspavlovs authored Sep 13, 2024
1 parent a12fa6f commit 6b040f2
Show file tree
Hide file tree
Showing 26 changed files with 110 additions and 84 deletions.
7 changes: 3 additions & 4 deletions cmd/config/init/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import (
"strings"

"github.com/BurntSushi/toml"
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/consts"
cmdutils "github.com/dymensionxyz/roller/cmd/utils"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/config"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/spf13/cobra"
)

func AddFlags(cmd *cobra.Command) error {
Expand Down Expand Up @@ -64,7 +63,7 @@ func GetInitConfig(
) (*config.RollappConfig, error) {
var cfg config.RollappConfig

home, err := globalutils.ExpandHomePath(initCmd.Flag(cmdutils.FlagNames.Home).Value.String())
home, err := filesystem.ExpandHomePath(initCmd.Flag(cmdutils.FlagNames.Home).Value.String())
if err != nil {
fmt.Println("failed to expand home path: ", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/config/set/da.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/dymensionxyz/roller/cmd/utils"
datalayer "github.com/dymensionxyz/roller/data_layer"
"github.com/dymensionxyz/roller/sequencer"
globalutils "github.com/dymensionxyz/roller/utils"
configutils "github.com/dymensionxyz/roller/utils/config"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/filesystem"
)

func setDA(rlpCfg configutils.RollappConfig, value string) error {
Expand All @@ -28,7 +28,7 @@ func setDA(rlpCfg configutils.RollappConfig, value string) error {

func updateDaConfig(rlpCfg configutils.RollappConfig, newDa consts.DAType) error {
daCfgDirPath := filepath.Join(rlpCfg.Home, consts.ConfigDirName.DALightNode)
dirExist, err := globalutils.DirNotEmpty(daCfgDirPath)
dirExist, err := filesystem.DirNotEmpty(daCfgDirPath)
if err != nil {
return err
}
Expand Down
9 changes: 5 additions & 4 deletions cmd/eibc/fulfill/denoms/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"os"
"path/filepath"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
eibcutils "github.com/dymensionxyz/roller/utils/eibc"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"

"github.com/dymensionxyz/roller/cmd/consts"
eibcutils "github.com/dymensionxyz/roller/utils/eibc"
"github.com/dymensionxyz/roller/utils/filesystem"
)

func Cmd() *cobra.Command {
Expand All @@ -25,7 +26,7 @@ func Cmd() *cobra.Command {
}

eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc)
isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome)
isEibcClientInitialized, err := filesystem.DirNotEmpty(eibcHome)
if err != nil {
pterm.Error.Println("failed to check eibc client initialized", err)
return
Expand Down
9 changes: 4 additions & 5 deletions cmd/eibc/fulfill/denoms/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import (
"os"
"path/filepath"

"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/utils/eibc"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/eibc"
)

func Cmd() *cobra.Command {
Expand All @@ -27,7 +26,7 @@ func Cmd() *cobra.Command {
}

eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc)
isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome)
isEibcClientInitialized, err := filesystem.DirNotEmpty(eibcHome)
if err != nil {
pterm.Error.Println("failed to check eibc client initialized", err)
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/eibc/fulfill/denoms/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"gopkg.in/yaml.v3"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/config/yamlconfig"
"github.com/dymensionxyz/roller/utils/filesystem"
)

func Cmd() *cobra.Command {
Expand All @@ -37,7 +37,7 @@ instance.
}

eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc)
isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome)
isEibcClientInitialized, err := filesystem.DirNotEmpty(eibcHome)
if err != nil {
pterm.Error.Println("failed to check eibc client initialized", err)
return
Expand Down
9 changes: 4 additions & 5 deletions cmd/eibc/fulfill/order/order.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ package order
import (
"fmt"

"github.com/pterm/pterm"
"github.com/spf13/cobra"

initconfig "github.com/dymensionxyz/roller/cmd/config/init"
"github.com/dymensionxyz/roller/cmd/utils"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/bash"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/eibc"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/dymensionxyz/roller/utils/tx"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
)

func Cmd() *cobra.Command {
Expand All @@ -27,7 +26,7 @@ func Cmd() *cobra.Command {
return
}

home, err := globalutils.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String())
home, err := filesystem.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String())
if err != nil {
pterm.Error.Println("failed to expand home directory")
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/eibc/fulfill/rollapps/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"path/filepath"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
eibcutils "github.com/dymensionxyz/roller/utils/eibc"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
Expand All @@ -25,7 +25,7 @@ func Cmd() *cobra.Command {
}

eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc)
isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome)
isEibcClientInitialized, err := filesystem.DirNotEmpty(eibcHome)
if err != nil {
pterm.Error.Println("failed to check eibc client initialized", err)
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/eibc/fulfill/rollapps/remove/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"path/filepath"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/eibc"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
Expand All @@ -25,7 +25,7 @@ func Cmd() *cobra.Command {
}

eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc)
isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome)
isEibcClientInitialized, err := filesystem.DirNotEmpty(eibcHome)
if err != nil {
pterm.Error.Println("failed to check eibc client initialized", err)
return
Expand Down
9 changes: 4 additions & 5 deletions cmd/eibc/fulfill/rollapps/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import (
"path/filepath"
"strconv"

"github.com/pterm/pterm"
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/config/yamlconfig"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
)

func Cmd() *cobra.Command {
Expand All @@ -35,7 +34,7 @@ instance.
}

eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc)
isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome)
isEibcClientInitialized, err := filesystem.DirNotEmpty(eibcHome)
if err != nil {
pterm.Error.Println("failed to check eibc client initialized", err)
return
Expand Down
6 changes: 3 additions & 3 deletions cmd/eibc/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
initconfig "github.com/dymensionxyz/roller/cmd/config/init"
"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/bash"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/config/yamlconfig"
eibcutils "github.com/dymensionxyz/roller/utils/eibc"
"github.com/dymensionxyz/roller/utils/errorhandling"
"github.com/dymensionxyz/roller/utils/filesystem"
)

func Cmd() *cobra.Command {
Expand All @@ -29,7 +29,7 @@ func Cmd() *cobra.Command {
return
}

rollerHome, err := globalutils.ExpandHomePath(
rollerHome, err := filesystem.ExpandHomePath(
cmd.Flag(utils.FlagNames.Home).Value.String(),
)
if err != nil {
Expand All @@ -50,7 +50,7 @@ func Cmd() *cobra.Command {
}

eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc)
isEibcClientInitialized, err := globalutils.DirNotEmpty(eibcHome)
isEibcClientInitialized, err := filesystem.DirNotEmpty(eibcHome)
if err != nil {
pterm.Error.Println("failed to check eibc client initialized", err)
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/eibc/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"path/filepath"

"github.com/dymensionxyz/roller/cmd/consts"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/bash"
eibcutils "github.com/dymensionxyz/roller/utils/eibc"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/spf13/cobra"
)

Expand All @@ -20,7 +20,7 @@ func Cmd() *cobra.Command {
Run: func(cmd *cobra.Command, args []string) {
home, _ := os.UserHomeDir()
eibcHome := filepath.Join(home, consts.ConfigDirName.Eibc)
ok, err := globalutils.DirNotEmpty(eibcHome)
ok, err := filesystem.DirNotEmpty(eibcHome)
if err != nil {
return
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/migrate/v_0_1_12.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/dymensionxyz/roller/utils"
configutils "github.com/dymensionxyz/roller/utils/config"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/filesystem"
)

type VersionMigratorV0112 struct{}
Expand All @@ -26,7 +27,7 @@ func (v *VersionMigratorV0112) PerformMigration(rlpCfg configutils.RollappConfig
}
if rlpCfg.DA.Backend == consts.Avail {
availNewCfgPath := avail.GetCfgFilePath(rlpCfg.Home)
if err := utils.MoveFile(filepath.Join(rlpCfg.Home, avail.ConfigFileName), availNewCfgPath); err != nil {
if err := filesystem.MoveFile(filepath.Join(rlpCfg.Home, avail.ConfigFileName), availNewCfgPath); err != nil {
return err
}
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/relayer/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/dymensionxyz/roller/utils/config/yamlconfig"
dymintutils "github.com/dymensionxyz/roller/utils/dymint"
"github.com/dymensionxyz/roller/utils/errorhandling"
"github.com/dymensionxyz/roller/utils/filesystem"
genesisutils "github.com/dymensionxyz/roller/utils/genesis"
rollapputils "github.com/dymensionxyz/roller/utils/rollapp"
)
Expand All @@ -37,7 +38,7 @@ func Cmd() *cobra.Command {
Use: "setup",
Short: "Setup IBC connection between the Dymension hub and the RollApp.",
Run: func(cmd *cobra.Command, args []string) {
home, _ := globalutils.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String())
home, _ := filesystem.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String())
relayerHome := filepath.Join(home, consts.ConfigDirName.Relayer)

genesis, err := comettypes.GenesisDocFromFile(genesisutils.GetGenesisFilePath(home))
Expand Down Expand Up @@ -93,7 +94,7 @@ func Cmd() *cobra.Command {
}
}()
outputHandler := initconfig.NewOutputHandler(false)
isRelayerInitialized, err := globalutils.DirNotEmpty(relayerHome)
isRelayerInitialized, err := filesystem.DirNotEmpty(relayerHome)
if err != nil {
pterm.Error.Printf("failed to check %s: %v\n", relayerHome, err)
return
Expand Down Expand Up @@ -123,7 +124,7 @@ func Cmd() *cobra.Command {
svcFileName := fmt.Sprintf("%s.service", svc)
svcFilePath := filepath.Join("/etc/systemd/system/", svcFileName)

err := globalutils.RemoveFileIfExists(svcFilePath)
err := filesystem.RemoveFileIfExists(svcFilePath)
if err != nil {
pterm.Error.Println("failed to remove systemd service: ", err)
return
Expand Down
7 changes: 3 additions & 4 deletions cmd/rollapp/init/mockbackends.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import (
"path/filepath"

"github.com/BurntSushi/toml"
"github.com/spf13/cobra"

"github.com/dymensionxyz/roller/cmd/utils"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/spf13/cobra"
)

type RollerConfig struct {
Expand All @@ -30,7 +29,7 @@ type RollerConfig struct {
}

func NewMockRollerConfig(cmd *cobra.Command) *RollerConfig {
home, _ := globalutils.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String())
home, _ := filesystem.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String())

return &RollerConfig{
BaseDenom: "amock",
Expand Down
7 changes: 4 additions & 3 deletions cmd/rollapp/init/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/dymensionxyz/roller/utils/config"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/errorhandling"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/dymensionxyz/roller/utils/genesis"
"github.com/dymensionxyz/roller/utils/sequencer"
"github.com/pelletier/go-toml/v2"
Expand All @@ -31,7 +32,7 @@ import (
)

func runInit(cmd *cobra.Command, env string, raID string) error {
home, err := globalutils.ExpandHomePath(cmd.Flag(cmdutils.FlagNames.Home).Value.String())
home, err := filesystem.ExpandHomePath(cmd.Flag(cmdutils.FlagNames.Home).Value.String())
if err != nil {
pterm.Error.Println("failed to expand home directory")
return err
Expand All @@ -49,7 +50,7 @@ func runInit(cmd *cobra.Command, env string, raID string) error {
outputHandler := initconfig.NewOutputHandler(false)

// TODO: extract into util
isRootExist, err := globalutils.DirNotEmpty(home)
isRootExist, err := filesystem.DirNotEmpty(home)
if err != nil {
errorhandling.PrettifyErrorIfExists(err)
return err
Expand All @@ -74,7 +75,7 @@ func runInit(cmd *cobra.Command, env string, raID string) error {
svcFileName := fmt.Sprintf("%s.service", svc)
svcFilePath := filepath.Join("/etc/systemd/system/", svcFileName)

err := globalutils.RemoveFileIfExists(svcFilePath)
err := filesystem.RemoveFileIfExists(svcFilePath)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/rollapp/sequencer/metadata/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
initconfig "github.com/dymensionxyz/roller/cmd/config/init"
"github.com/dymensionxyz/roller/cmd/consts"
"github.com/dymensionxyz/roller/cmd/utils"
globalutils "github.com/dymensionxyz/roller/utils"
"github.com/dymensionxyz/roller/utils/config/tomlconfig"
"github.com/dymensionxyz/roller/utils/errorhandling"
"github.com/dymensionxyz/roller/utils/filesystem"
"github.com/dymensionxyz/roller/utils/sequencer"
sequencerutils "github.com/dymensionxyz/roller/utils/sequencer"
"github.com/dymensionxyz/roller/utils/structs"
Expand All @@ -29,7 +29,7 @@ func Cmd() *cobra.Command {
return
}

home, err := globalutils.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String())
home, err := filesystem.ExpandHomePath(cmd.Flag(utils.FlagNames.Home).Value.String())
if err != nil {
pterm.Error.Println("failed to expand home directory")
return
Expand Down
Loading

0 comments on commit 6b040f2

Please sign in to comment.