Skip to content

Commit

Permalink
lint & pr comments [1]
Browse files Browse the repository at this point in the history
  • Loading branch information
swift1337 committed Nov 6, 2024
1 parent d5f72a6 commit 932210c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cmd/zetaclientd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
RunE: TSSEncryptFile,
}
TSSGeneratePreParamsCmd = &cobra.Command{
Use: "tss gen-pre-params [path]",
Use: "gen-pre-params [path]",
Short: "Generate pre parameters for TSS",
Args: cobra.ExactArgs(1),
RunE: TSSGeneratePreParams,
Expand Down
64 changes: 32 additions & 32 deletions cmd/zetaclientd/relayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"github.com/zeta-chain/node/zetaclient/keys"
)

// privateKey is the struct that holds arguments for the relayer commands
// relayerOptions is the struct that holds arguments for the relayer commands
type relayerOptions struct {
privateKey string
network uint32
network int32
password string
relayerKeyPath string
}
Expand All @@ -32,7 +32,7 @@ func setupRelayerOptions() {
// resolve default relayer key path
defaultKeyPath := fmt.Sprintf("%s/%s", app.DefaultNodeHome, config.DefaultRelayerDir)

f.Uint32Var(&cfg.network, "network", 7, "network id, (7:solana)")
f.Int32Var(&cfg.network, "network", 7, "network id, (7:solana)")
f.StringVar(&cfg.password, "password", "", "the password to decrypt the relayer private key")
f.StringVar(&cfg.relayerKeyPath, "key-path", defaultKeyPath, "path to relayer keys")

Expand All @@ -41,6 +41,35 @@ func setupRelayerOptions() {
f.StringVar(&cfg.privateKey, "private-key", "", "the relayer private key to import")
}

// RelayerShowAddress shows the relayer address
func RelayerShowAddress(_ *cobra.Command, _ []string) error {
// try loading the relayer key if present
network := chains.Network(relayerOpts.network)
relayerKey, err := keys.LoadRelayerKey(relayerOpts.relayerKeyPath, network, relayerOpts.password)
if err != nil {
return errors.Wrap(err, "failed to load relayer key")
}

// relayer key does not exist, return error
if relayerKey == nil {
return fmt.Errorf(
"relayer key not found for network %d in path: %s",
relayerOpts.network,
relayerOpts.relayerKeyPath,
)
}

// resolve the relayer address
networkName, address, err := relayerKey.ResolveAddress(network)
if err != nil {
return errors.Wrap(err, "failed to resolve relayer address")
}

fmt.Printf("relayer address (%s): %s\n", networkName, address)

return nil
}

// RelayerImportKey imports a relayer private key
func RelayerImportKey(_ *cobra.Command, _ []string) error {
// validate private key and password
Expand Down Expand Up @@ -90,32 +119,3 @@ func RelayerImportKey(_ *cobra.Command, _ []string) error {

return nil
}

// RelayerShowAddress shows the relayer address
func RelayerShowAddress(_ *cobra.Command, _ []string) error {
// try loading the relayer key if present
network := chains.Network(relayerOpts.network)
relayerKey, err := keys.LoadRelayerKey(relayerOpts.relayerKeyPath, network, relayerOpts.password)
if err != nil {
return errors.Wrap(err, "failed to load relayer key")
}

// relayer key does not exist, return error
if relayerKey == nil {
return fmt.Errorf(
"relayer key not found for network %d in path: %s",
relayerOpts.network,
relayerOpts.relayerKeyPath,
)
}

// resolve the relayer address
networkName, address, err := relayerKey.ResolveAddress(network)
if err != nil {
return errors.Wrap(err, "failed to resolve relayer address")
}

fmt.Printf("relayer address (%s): %s\n", networkName, address)

return nil
}
1 change: 1 addition & 0 deletions cmd/zetaclientd/tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func TSSEncryptFile(_ *cobra.Command, args []string) error {
password = args[1]
)

// #nosec G304 -- this is a config file
data, err := os.ReadFile(filePath)
if err != nil {
return err
Expand Down

0 comments on commit 932210c

Please sign in to comment.