diff --git a/cmd/lilypad/pow_signal.go b/cmd/lilypad/pow_signal.go index 266b0d5b..9af12075 100644 --- a/cmd/lilypad/pow_signal.go +++ b/cmd/lilypad/pow_signal.go @@ -18,10 +18,15 @@ func newPowSignalCmd() *cobra.Command { Long: "Send a pow signal to smart contract.", Example: "", RunE: func(cmd *cobra.Command, _ []string) error { - network, _ := cmd.Flags().GetString("network") + network, err := cmd.Flags().GetString("network") + if err != nil { + log.Error().Err(err).Msg("Failed to retrieve 'network' flag") + return err + } options, err := optionsfactory.ProcessPowSignalOptions(options, network) if err != nil { + log.Error().Err(err).Msg("Failed to process PowSignal options") return err } return runPowSignal(cmd, options) @@ -39,6 +44,7 @@ func runPowSignal(cmd *cobra.Command, options options.PowSignalOptions) error { web3SDK, err := web3.NewContractSDK(options.Web3) if err != nil { + log.Error().Err(err).Msg("Failed to initialize Web3 SDK") return err } @@ -46,6 +52,6 @@ func runPowSignal(cmd *cobra.Command, options options.PowSignalOptions) error { if err != nil { return err } - log.Info().Msgf("send pow signal successful.") + log.Info().Msg("Send pow signal successful.") return nil } diff --git a/cmd/lilypad/root.go b/cmd/lilypad/root.go index 48038777..cc6dbd65 100644 --- a/cmd/lilypad/root.go +++ b/cmd/lilypad/root.go @@ -25,6 +25,9 @@ func NewRootCmd() *cobra.Command { var network string RootCmd.PersistentFlags().StringVarP(&network, "network", "n", "testnet", "Sets a target network configuration") + var powSignalCmd bool + RootCmd.PersistentFlags().BoolVarP(&powSignalCmd, "pow-signal", "", false, "Send a pow signal to smart contract") + RootCmd.AddCommand(newSolverCmd()) RootCmd.AddCommand(newResourceProviderCmd()) RootCmd.AddCommand(newPowSignalCmd()) diff --git a/pkg/options/resource-provider.go b/pkg/options/resource-provider.go index f829090f..a63569fb 100644 --- a/pkg/options/resource-provider.go +++ b/pkg/options/resource-provider.go @@ -2,6 +2,7 @@ package options import ( "fmt" + "os" "github.com/lilypad-tech/lilypad/pkg/data" "github.com/lilypad-tech/lilypad/pkg/resourceprovider" @@ -106,7 +107,8 @@ func AddResourceProviderPowCliFlags(cmd *cobra.Command, options *resourceprovide &options.CudaHashsPerThread, "cuda-hash-per-thread", options.CudaHashsPerThread, `Cuda hash per threads (CUDA_HASH_PER_THREAD)`, ) - + // Explicitly parse flags for the CLI options + cmd.ParseFlags(os.Args) } func AddResourceProviderCliFlags(cmd *cobra.Command, options *resourceprovider.ResourceProviderOptions) {