Skip to content

Commit 503a67f

Browse files
committed
fix: use helper functions
1 parent a6f712c commit 503a67f

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

cmd/p2p/nodelist/nodelist.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"encoding/json"
55
"os"
66

7+
"github.com/0xPolygon/polygon-cli/flag"
78
"github.com/0xPolygon/polygon-cli/p2p/database"
8-
"github.com/rs/zerolog/log"
99
"github.com/spf13/cobra"
1010
)
1111

@@ -61,7 +61,5 @@ func init() {
6161
f.IntVarP(&inputNodeListParams.Limit, "limit", "l", 100, "number of unique nodes to return")
6262
f.StringVarP(&inputNodeListParams.ProjectID, "project-id", "p", "", "GCP project ID")
6363
f.StringVarP(&inputNodeListParams.DatabaseID, "database-id", "d", "", "datastore database ID")
64-
if err := NodeListCmd.MarkFlagRequired("project-id"); err != nil {
65-
log.Error().Err(err).Msg("Failed to mark project-id as required flag")
66-
}
64+
flag.MarkFlagRequired(NodeListCmd, "project-id")
6765
}

cmd/p2p/query/query.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import (
66
"net"
77

88
"github.com/ethereum/go-ethereum/eth/protocols/eth"
9-
"github.com/rs/zerolog/log"
109
"github.com/spf13/cobra"
1110

11+
"github.com/0xPolygon/polygon-cli/flag"
1212
"github.com/0xPolygon/polygon-cli/p2p"
1313
)
1414

@@ -132,7 +132,5 @@ func init() {
132132
f.StringVarP(&inputQueryParams.KeyFile, "key-file", "k", "", "private key file (cannot be set with --key)")
133133
f.StringVar(&inputQueryParams.PrivateKey, "key", "", "hex-encoded private key (cannot be set with --key-file)")
134134
QueryCmd.MarkFlagsMutuallyExclusive("key-file", "key")
135-
if err := QueryCmd.MarkFlagRequired("start-block"); err != nil {
136-
log.Error().Err(err).Msg("Failed to mark start-block as required flag")
137-
}
135+
flag.MarkFlagRequired(QueryCmd, "start-block")
138136
}

cmd/p2p/sensor/sensor.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
"github.com/rs/zerolog/log"
2929
"github.com/spf13/cobra"
3030

31+
"github.com/0xPolygon/polygon-cli/flag"
3132
"github.com/0xPolygon/polygon-cli/p2p"
3233
"github.com/0xPolygon/polygon-cli/p2p/database"
3334
"github.com/0xPolygon/polygon-cli/rpctypes"
@@ -419,15 +420,11 @@ func init() {
419420
f := SensorCmd.Flags()
420421
f.StringVarP(&inputSensorParams.Bootnodes, "bootnodes", "b", "", "comma separated nodes used for bootstrapping")
421422
f.Uint64VarP(&inputSensorParams.NetworkID, "network-id", "n", 0, "filter discovered nodes by this network ID")
422-
if err := SensorCmd.MarkFlagRequired("network-id"); err != nil {
423-
log.Error().Err(err).Msg("Failed to mark network-id as required persistent flag")
424-
}
423+
flag.MarkFlagRequired(SensorCmd, "network-id")
425424
f.StringVarP(&inputSensorParams.ProjectID, "project-id", "p", "", "GCP project ID")
426425
f.StringVarP(&inputSensorParams.DatabaseID, "database-id", "d", "", "datastore database ID")
427426
f.StringVarP(&inputSensorParams.SensorID, "sensor-id", "s", "", "sensor ID when writing block/tx events")
428-
if err := SensorCmd.MarkFlagRequired("sensor-id"); err != nil {
429-
log.Error().Err(err).Msg("Failed to mark sensor-id as required persistent flag")
430-
}
427+
flag.MarkFlagRequired(SensorCmd, "sensor-id")
431428
f.IntVarP(&inputSensorParams.MaxPeers, "max-peers", "m", 2000, "maximum number of peers to connect to")
432429
f.IntVarP(&inputSensorParams.MaxDatabaseConcurrency, "max-db-concurrency", "D", 10000,
433430
`maximum number of concurrent database operations to perform (increasing this

cmd/ulxly/ulxly.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,9 +2307,9 @@ func (o *GetEvent) AddFlags(cmd *cobra.Command) {
23072307
f.Uint64VarP(&o.ToBlock, ArgToBlock, "t", 0, "end of the range of blocks to retrieve")
23082308
f.Uint64VarP(&o.FilterSize, ArgFilterSize, "i", 1000, "batch size for individual filter queries")
23092309
f.BoolVarP(&o.Insecure, ArgInsecure, "", false, "skip TLS certificate verification")
2310-
fatalIfError(cmd.MarkFlagRequired(ArgFromBlock))
2311-
fatalIfError(cmd.MarkFlagRequired(ArgToBlock))
2312-
fatalIfError(cmd.MarkFlagRequired(ArgRPCURL))
2310+
flag.MarkFlagRequired(cmd, ArgFromBlock)
2311+
flag.MarkFlagRequired(cmd, ArgToBlock)
2312+
flag.MarkFlagRequired(cmd, ArgRPCURL)
23132313
}
23142314

23152315
type GetSmcOptions struct {
@@ -2547,7 +2547,7 @@ or if it's actually an intermediate hash.`,
25472547
fBridgeAndClaim.StringVar(&inputUlxlyArgs.gasPrice, ArgGasPrice, "", "gas price to use")
25482548
fBridgeAndClaim.BoolVar(&inputUlxlyArgs.dryRun, ArgDryRun, false, "do all of the transaction steps but do not send the transaction")
25492549
fBridgeAndClaim.BoolVar(&inputUlxlyArgs.insecure, ArgInsecure, false, "skip TLS certificate verification")
2550-
fatalIfError(ulxlyBridgeAndClaimCmd.MarkPersistentFlagRequired(ArgBridgeAddress))
2550+
flag.MarkPersistentFlagRequired(ulxlyBridgeAndClaimCmd, ArgBridgeAddress)
25512551

25522552
// bridge specific args
25532553
fBridge := ulxlyBridgeCmd.PersistentFlags()
@@ -2557,7 +2557,7 @@ or if it's actually an intermediate hash.`,
25572557
fBridge.StringVar(&inputUlxlyArgs.tokenAddress, ArgTokenAddress, "0x0000000000000000000000000000000000000000", "address of ERC20 token to use")
25582558
fBridge.StringVar(&inputUlxlyArgs.callData, ArgCallData, "0x", "call data to be passed directly with bridge-message or as an ERC20 Permit")
25592559
fBridge.StringVar(&inputUlxlyArgs.callDataFile, ArgCallDataFile, "", "a file containing hex encoded call data")
2560-
fatalIfError(ulxlyBridgeCmd.MarkPersistentFlagRequired(ArgDestNetwork))
2560+
flag.MarkPersistentFlagRequired(ulxlyBridgeCmd, ArgDestNetwork)
25612561

25622562
// Claim specific args
25632563
fClaim := ulxlyClaimCmd.PersistentFlags()
@@ -2566,9 +2566,9 @@ or if it's actually an intermediate hash.`,
25662566
fClaim.StringVar(&inputUlxlyArgs.bridgeServiceURL, ArgBridgeServiceURL, "", "URL of the bridge service")
25672567
fClaim.StringVar(&inputUlxlyArgs.globalIndex, ArgGlobalIndex, "", "an override of the global index value")
25682568
fClaim.DurationVar(&inputUlxlyArgs.wait, ArgWait, time.Duration(0), "retry claiming until deposit is ready, up to specified duration (available for claim asset and claim message)")
2569-
fatalIfError(ulxlyClaimCmd.MarkPersistentFlagRequired(ArgDepositCount))
2570-
fatalIfError(ulxlyClaimCmd.MarkPersistentFlagRequired(ArgDepositNetwork))
2571-
fatalIfError(ulxlyClaimCmd.MarkPersistentFlagRequired(ArgBridgeServiceURL))
2569+
flag.MarkPersistentFlagRequired(ulxlyClaimCmd, ArgDepositCount)
2570+
flag.MarkPersistentFlagRequired(ulxlyClaimCmd, ArgDepositNetwork)
2571+
flag.MarkPersistentFlagRequired(ulxlyClaimCmd, ArgBridgeServiceURL)
25722572

25732573
// Claim Everything Helper Command
25742574
fClaimEverything := claimEverythingCommand.Flags()
@@ -2577,7 +2577,7 @@ or if it's actually an intermediate hash.`,
25772577
fClaimEverything.IntVar(&inputUlxlyArgs.bridgeOffset, ArgBridgeOffset, 0, "offset to specify for pagination of underlying bridge service deposits")
25782578
fClaimEverything.UintVar(&inputUlxlyArgs.concurrency, ArgConcurrency, 1, "worker pool size for claims")
25792579

2580-
fatalIfError(claimEverythingCommand.MarkFlagRequired(ArgBridgeMappings))
2580+
flag.MarkFlagRequired(claimEverythingCommand, ArgBridgeMappings)
25812581

25822582
// Top Level
25832583
ULxLyCmd.AddCommand(ulxlyBridgeAndClaimCmd)

0 commit comments

Comments
 (0)