diff --git a/cmd/relayer/setup/setup.go b/cmd/relayer/setup/setup.go index 1d4fd252..3706d790 100644 --- a/cmd/relayer/setup/setup.go +++ b/cmd/relayer/setup/setup.go @@ -49,11 +49,6 @@ func Cmd() *cobra.Command { relayerLogFilePath := logging.GetRelayerLogPath(home) relayerLogger := logging.GetLogger(relayerLogFilePath) rly.SetLogger(relayerLogger) - err = rly.Config.Load(rly.ConfigFilePath) - if err != nil { - pterm.Error.Println("failed to load relayer config: ", err) - return - } rollappChainData, err := rollapp.PopulateRollerConfigWithRaMetadataFromChain( home, @@ -68,6 +63,13 @@ func Cmd() *cobra.Command { } pterm.Info.Println("rollapp chain data validation passed") + var rlyCfg relayer.Config + err = rlyCfg.Load(rly.ConfigFilePath) + if err != nil { + pterm.Error.Println("failed to load relayer config: ", err) + return + } + // err = installRelayerDependencies(home, raID, *hd) // if err != nil { // pterm.Error.Println("failed to install relayer dependencies: ", err) @@ -89,9 +91,9 @@ func Cmd() *cobra.Command { return } - if rly.Config.GetPath() == nil { + if rlyCfg.GetPath() == nil { pterm.Error.Println("no existing path") - if err := rly.Config.CreatePath(*rollappChainData); err != nil { + if err := rlyCfg.CreatePath(*rollappChainData); err != nil { pterm.Error.Printf("failed to create relayer IBC path: %v\n", err) return } diff --git a/cmd/relayer/status/status.go b/cmd/relayer/status/status.go index cd43d714..adfc5abe 100644 --- a/cmd/relayer/status/status.go +++ b/cmd/relayer/status/status.go @@ -45,7 +45,6 @@ func Cmd() *cobra.Command { *raData, *hd, ) - rly.Config = &rlyCfg bytes, err := os.ReadFile(rly.StatusFilePath()) if err != nil { diff --git a/relayer/config.go b/relayer/config.go index 4070b0e4..131bc8c5 100644 --- a/relayer/config.go +++ b/relayer/config.go @@ -68,6 +68,21 @@ type Paths struct { } `yaml:"hub-rollapp"` } +func (c *Config) Load(rlyConfigPath string) error { + fmt.Println("loading config from", rlyConfigPath) + data, err := os.ReadFile(rlyConfigPath) + if err != nil { + return err + } + + err = yaml.Unmarshal(data, c) + if err != nil { + return err + } + + return nil +} + func (c *Config) GetPath() *Paths { if c.Paths == nil || c.Paths.HubRollapp == nil { return nil diff --git a/relayer/relayer_manager.go b/relayer/relayer_manager.go index 7ee1d949..051a1df1 100644 --- a/relayer/relayer_manager.go +++ b/relayer/relayer_manager.go @@ -8,8 +8,6 @@ import ( "os" "path/filepath" - yaml "gopkg.in/yaml.v3" - "github.com/dymensionxyz/roller/cmd/consts" "github.com/dymensionxyz/roller/utils/roller" ) @@ -31,8 +29,6 @@ type Relayer struct { SrcClientID string DstClientID string - Config *Config - logger *log.Logger } @@ -86,17 +82,3 @@ type ConnectionChannels struct { Src string Dst string } - -func (c *Config) Load(rlyConfigPath string) error { - data, err := os.ReadFile(rlyConfigPath) - if err != nil { - return err - } - - err = yaml.Unmarshal(data, c) - if err != nil { - return err - } - - return nil -}