Skip to content

Commit

Permalink
Merge PR #211: UX-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzampolin authored May 1, 2020
1 parent f1ee63e commit 09c587e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func timeoutFlag(cmd *cobra.Command) *cobra.Command {
}

func forceFlag(cmd *cobra.Command) *cobra.Command {
cmd.Flags().BoolP(flagForce, "f", false, "option to force initialization of lite client from configured chain")
cmd.Flags().BoolP(flagForce, "f", false, "option to force non-standard behavior such as initialization of lite client from configured chain or generation of new path")
if err := viper.BindPFlag(flagForce, cmd.Flags().Lookup(flagForce)); err != nil {
panic(err)
}
Expand Down
24 changes: 22 additions & 2 deletions cmd/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func pathsGenCmd() *cobra.Command {

unordered, err := cmd.Flags().GetBool(flagOrder)
if err != nil {
return nil
return err
}

if unordered {
Expand All @@ -91,6 +91,24 @@ func pathsGenCmd() *cobra.Command {
path.Dst.Order = "ORDERED"
}

force, err := cmd.Flags().GetBool(flagForce)
if err != nil {
return err
}

if force {
path.Dst.ClientID = relayer.RandLowerCaseLetterString(10)
path.Src.ClientID = relayer.RandLowerCaseLetterString(10)
path.Src.ConnectionID = relayer.RandLowerCaseLetterString(10)
path.Dst.ConnectionID = relayer.RandLowerCaseLetterString(10)
path.Src.ChannelID = relayer.RandLowerCaseLetterString(10)
path.Dst.ChannelID = relayer.RandLowerCaseLetterString(10)
if err = config.Paths.AddForce(args[4], path); err != nil {
return err
}
return overWriteConfig(cmd, config)
}

srcClients, err := c[src].QueryClients(1, 1000)
if err != nil {
return err
Expand Down Expand Up @@ -265,7 +283,7 @@ func pathsGenCmd() *cobra.Command {
}
},
}
return orderFlag(cmd)
return forceFlag(orderFlag(cmd))
}

func pathsDeleteCmd() *cobra.Command {
Expand Down Expand Up @@ -601,9 +619,11 @@ func userInputPathAdd(src, dst, name string) (*Config, error) {
Strategy: relayer.NewNaiveStrategy(),
Src: &relayer.PathEnd{
ChainID: src,
Order: "ORDERED",
},
Dst: &relayer.PathEnd{
ChainID: dst,
Order: "ORDERED",
},
}
)
Expand Down
7 changes: 3 additions & 4 deletions dev-env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

RELAYER_DIR="$GOPATH/src/github.com/iqlusioninc/relayer"
RELAYER_CONF="$HOME/.relayer"
GAIA_CONF="$RELAYER_DIR/data"
GAIA_CONF="$(pwd)/data"

# Ensure user understands what will be deleted
if ([[ -d $RELAYER_CONF ]] || [[ -d $GAIA_CONF ]]) && [[ ! "$1" == "skip" ]]; then
Expand All @@ -15,8 +15,7 @@ fi

cd $RELAYER_DIR
rm -rf $RELAYER_CONF &> /dev/null
bash scripts/three-chainz "local" "skip"
bash scripts/config-three "skip"
./scripts/two-chainz "local" "skip"
./scripts/config-relayer "skip"
sleep 2
rly tx link demo -o 3s
rly tx link demo2 -o 3s -d
1 change: 1 addition & 0 deletions relayer/client-tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func (src *Chain) CreateClients(dst *Chain) (err error) {
} else if srcCs == nil {
dstH, err := dst.UpdateLiteWithHeader()
if err != nil {
// fmt.Println("Herere")
return err
}
if src.debug {
Expand Down
12 changes: 12 additions & 0 deletions relayer/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ func (p Paths) Add(name string, path *Path) error {
return nil
}

// AddForce ignores existing paths and overwrites an existing path with that name
func (p Paths) AddForce(name string, path *Path) error {
if err := path.Validate(); err != nil {
return err
}
if _, found := p[name]; found {
fmt.Printf("overwriting path %s with new path...\n", name)
}
p[name] = path
return nil
}

// MustYAML returns the yaml string representation of the Path
func (p *Path) MustYAML() string {
out, err := yaml.Marshal(p)
Expand Down

0 comments on commit 09c587e

Please sign in to comment.