Skip to content

Commit

Permalink
fix: nil receiver initiate for path (#1177)
Browse files Browse the repository at this point in the history
* fix nil receiver initiate for path

ensure path get written to config

* add change doc
  • Loading branch information
mmsqe authored Apr 26, 2023
1 parent 3a14f8c commit 1ee79e5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [\#466](https://github.com/cosmos/relayer/pull/466) Docs cleanup.
* [\#506](https://github.com/cosmos/relayer/pull/506) Fix Timeout Handling on Relayer restart
* [\#940](https://github.com/cosmos/relayer/pull/940) Add min-gas-amount parameter for chain configs, to workaround gas estimation failure.
* [\#1177](https://github.com/cosmos/relayer/pull/1177) Avoid panic due to nil map when add new path and ensure path get written to config.

## v0.9.3

Expand Down
4 changes: 2 additions & 2 deletions cmd/appstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (a *appState) addPathFromFile(ctx context.Context, stderr io.Writer, file,
return err
}

return a.config.Paths.Add(name, p)
return a.config.AddPath(name, p)
}

// addPathFromUserInput manually prompts the user to specify all the path details.
Expand Down Expand Up @@ -169,7 +169,7 @@ func (a *appState) addPathFromUserInput(
return err
}

return a.config.Paths.Add(name, path)
return a.config.AddPath(name, path)
}

func (a *appState) performConfigLockingOperation(ctx context.Context, operation func() error) error {
Expand Down
8 changes: 6 additions & 2 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"reflect"
"strings"
"time"

"github.com/cosmos/relayer/v2/relayer"
"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
"github.com/cosmos/relayer/v2/relayer/chains/penumbra"
Expand Down Expand Up @@ -545,6 +545,10 @@ func checkPathEndConflict(pathID, direction string, oldPe, newPe *relayer.PathEn

// AddPath adds an additional path to the config
func (c *Config) AddPath(name string, path *relayer.Path) (err error) {
// Ensure path is initialized.
if c.Paths == nil {
c.Paths = make(relayer.Paths)
}
// Check if the path does not yet exist.
oldPath, err := c.Paths.Get(name)
if err != nil {
Expand Down Expand Up @@ -668,4 +672,4 @@ func (c *Config) ValidateConnection(ctx context.Context, chain *relayer.Chain, h
}

return nil
}
}
2 changes: 1 addition & 1 deletion cmd/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ $ %s pth n ibc-0 ibc-1 demo-path`, appName, appName)),
}

name := args[2]
if err = a.config.Paths.Add(name, p); err != nil {
if err = a.config.AddPath(name, p); err != nil {
return err
}
return nil
Expand Down

0 comments on commit 1ee79e5

Please sign in to comment.