Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
keyleu committed Dec 8, 2023
1 parent 6ddb07d commit 95d8b6b
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
1 change: 1 addition & 0 deletions relayer/cmd/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func addHomeFlag(cmd *cobra.Command) {
cmd.PersistentFlags().String(FlagHome, DefaultHomeDir, "Relayer home directory")
}

//nolint:lll // TODO(dzmitryhil) linter length limit
func addKeyringFlags(cmd *cobra.Command) {
cmd.PersistentFlags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)")
cmd.PersistentFlags().String(flags.FlagKeyringDir, path.Join(DefaultHomeDir, "keys"), "The client Keyring directory; if omitted, the default 'home' directory will be used")
Expand Down
51 changes: 0 additions & 51 deletions relayer/cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package main

import (
"bufio"
"context"
"fmt"
"os"
"time"

"github.com/cosmos/cosmos-sdk/client"
"github.com/pkg/errors"
Expand Down Expand Up @@ -49,51 +46,3 @@ func RootCmd(ctx context.Context) *cobra.Command {

return cmd
}

// StartCmd returns the start cmd.
func StartCmd(ctx context.Context) *cobra.Command {
cmd := &cobra.Command{
Use: "start",
Short: "Start relayer.",
RunE: func(cmd *cobra.Command, args []string) error {
// scan helps to wait for any input infinitely and just then call the relayer. That handles
// the relayer restart in the container. Because after the restart the container is detached, relayer
// requests the keyring password and fail inanimately.
// TODO(dzmitryhil) replace to logger once we integrate the runner
fmt.Print("Press any key to start the relayer.")
input := bufio.NewScanner(os.Stdin)
input.Scan()

// that code is just for an example and will be replaced later
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return errors.Wrap(err, "failed to get client context")
}
keyRecord, err := clientCtx.Keyring.Key(relayerKeyName)
if err != nil {
return errors.Wrap(err, "failed to get key from keyring")
}
address, err := keyRecord.GetAddress()
if err != nil {
return errors.Wrap(err, "failed to get address from the key record")
}
for {
select {
case <-ctx.Done():
return nil
case <-time.After(time.Second):
fmt.Printf("Address from the keyring:%s\n", address.String())
}
}
},
}
addKeyringFlags(cmd)

return cmd
}

//nolint:lll // TODO(dzmitryhil) linter length limit
func addKeyringFlags(cmd *cobra.Command) {
cmd.PersistentFlags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|kwallet|pass|test)")
cmd.PersistentFlags().String(flags.FlagKeyringDir, defaultKeyringDir, "The client Keyring directory; if omitted, the default 'home' directory will be used")
}

0 comments on commit 95d8b6b

Please sign in to comment.