Skip to content

Commit fac5e54

Browse files
committed
chore: lint + cleanup
Signed-off-by: Ji Hwan <[email protected]>
1 parent a7ef15a commit fac5e54

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

cmd/ulxly/ulxly.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func readDeposit(cmd *cobra.Command) error {
122122
var rpc *ethrpc.Client
123123
var err error
124124

125-
if getEvent.insecure != nil && *getEvent.insecure {
125+
if getEvent.Insecure {
126126
client, clientErr := createInsecureEthClient(rpcUrl)
127127
if clientErr != nil {
128128
log.Error().Err(clientErr).Msg("Unable to create insecure client")
@@ -212,7 +212,7 @@ func readClaim(cmd *cobra.Command) error {
212212
var rpc *ethrpc.Client
213213
var err error
214214

215-
if getEvent.insecure != nil && *getEvent.insecure {
215+
if getEvent.Insecure {
216216
client, clientErr := createInsecureEthClient(rpcUrl)
217217
if clientErr != nil {
218218
log.Error().Err(clientErr).Msg("Unable to create insecure client")
@@ -292,7 +292,7 @@ func readVerifyBatches(cmd *cobra.Command) error {
292292
var rpc *ethrpc.Client
293293
var err error
294294

295-
if getEvent.insecure != nil && *getEvent.insecure {
295+
if getEvent.Insecure {
296296
client, clientErr := createInsecureEthClient(rpcUrl)
297297
if clientErr != nil {
298298
log.Error().Err(clientErr).Msg("Unable to create insecure client")
@@ -370,7 +370,7 @@ func balanceTree() error {
370370
var client *ethclient.Client
371371
var err error
372372

373-
if balanceTreeOptions.insecure != nil && *balanceTreeOptions.insecure {
373+
if balanceTreeOptions.Insecure {
374374
client, err = createInsecureEthClient(balanceTreeOptions.RpcURL)
375375
} else {
376376
client, err = ethclient.DialContext(context.Background(), balanceTreeOptions.RpcURL)
@@ -420,7 +420,7 @@ func nullifierAndBalanceTree(args []string) error {
420420
var client *ethclient.Client
421421
var err error
422422

423-
if balanceTreeOptions.insecure != nil && *balanceTreeOptions.insecure {
423+
if balanceTreeOptions.Insecure {
424424
client, err = createInsecureEthClient(balanceTreeOptions.RpcURL)
425425
} else {
426426
client, err = ethclient.DialContext(context.Background(), balanceTreeOptions.RpcURL)
@@ -1867,7 +1867,7 @@ func generateTransactionPayload(ctx context.Context, client *ethclient.Client, u
18671867

18681868
// Helper function to get the appropriate HTTP client
18691869
func getHTTPClient() *http.Client {
1870-
if inputUlxlyArgs.insecure != nil && *inputUlxlyArgs.insecure {
1870+
if *inputUlxlyArgs.insecure {
18711871
log.Warn().Msg("WARNING: Using insecure HTTP client for bridge service requests")
18721872
return &http.Client{
18731873
Timeout: 30 * time.Second,
@@ -2022,7 +2022,7 @@ func createInsecureEthClient(rpcURL string) (*ethclient.Client, error) {
20222022
},
20232023
}
20242024

2025-
rpcClient, err := ethrpc.DialHTTPWithClient(rpcURL, httpClient)
2025+
rpcClient, err := ethrpc.DialOptions(context.Background(), rpcURL, ethrpc.WithHTTPClient(httpClient))
20262026
if err != nil {
20272027
return nil, err
20282028
}
@@ -2032,7 +2032,7 @@ func createInsecureEthClient(rpcURL string) (*ethclient.Client, error) {
20322032

20332033
// Add helper function to create either secure or insecure client based on flag
20342034
func createEthClient(ctx context.Context, rpcURL string) (*ethclient.Client, error) {
2035-
if inputUlxlyArgs.insecure != nil && *inputUlxlyArgs.insecure {
2035+
if *inputUlxlyArgs.insecure {
20362036
return createInsecureEthClient(rpcURL)
20372037
}
20382038
return ethclient.DialContext(ctx, rpcURL)
@@ -2216,6 +2216,7 @@ const (
22162216
ArgBridgeOffset = "bridge-offset"
22172217
ArgWait = "wait"
22182218
ArgConcurrency = "concurrency"
2219+
ArgInsecure = "insecure"
22192220
)
22202221

22212222
func prepInputs(cmd *cobra.Command, args []string) error {
@@ -2274,7 +2275,7 @@ func (o *FileOptions) AddFlags(cmd *cobra.Command) {
22742275
type BalanceTreeOptions struct {
22752276
L2ClaimsFile, L2DepositsFile, BridgeAddress, RpcURL string
22762277
L2NetworkID uint32
2277-
insecure *bool
2278+
Insecure bool
22782279
}
22792280

22802281
func (o *BalanceTreeOptions) AddFlags(cmd *cobra.Command) {
@@ -2283,7 +2284,7 @@ func (o *BalanceTreeOptions) AddFlags(cmd *cobra.Command) {
22832284
cmd.Flags().StringVarP(&o.BridgeAddress, ArgBridgeAddress, "", "", "Bridge Address")
22842285
cmd.Flags().StringVarP(&o.RpcURL, ArgRPCURL, "r", "", "RPC URL")
22852286
cmd.Flags().Uint32VarP(&o.L2NetworkID, ArgL2NetworkID, "", 0, "The L2 networkID")
2286-
o.insecure = cmd.Flags().Bool("insecure", false, "skip TLS certificate verification (development only)")
2287+
cmd.Flags().BoolVarP(&o.Insecure, ArgInsecure, "", false, "skip TLS certificate verification")
22872288
}
22882289

22892290
type ProofOptions struct {
@@ -2307,15 +2308,15 @@ func (o *RollupsProofOptions) AddFlags(cmd *cobra.Command) {
23072308
type GetEvent struct {
23082309
URL string
23092310
FromBlock, ToBlock, FilterSize uint64
2310-
insecure *bool
2311+
Insecure bool
23112312
}
23122313

23132314
func (o *GetEvent) AddFlags(cmd *cobra.Command) {
23142315
cmd.Flags().StringVarP(&o.URL, ArgRPCURL, "u", "", "The RPC URL to read the events data")
23152316
cmd.Flags().Uint64VarP(&o.FromBlock, ArgFromBlock, "f", 0, "The start of the range of blocks to retrieve")
23162317
cmd.Flags().Uint64VarP(&o.ToBlock, ArgToBlock, "t", 0, "The end of the range of blocks to retrieve")
23172318
cmd.Flags().Uint64VarP(&o.FilterSize, ArgFilterSize, "i", 1000, "The batch size for individual filter queries")
2318-
o.insecure = cmd.Flags().Bool("insecure", false, "skip TLS certificate verification")
2319+
cmd.Flags().BoolVarP(&o.Insecure, ArgInsecure, "", false, "skip TLS certificate verification")
23192320
fatalIfError(cmd.MarkFlagRequired(ArgFromBlock))
23202321
fatalIfError(cmd.MarkFlagRequired(ArgToBlock))
23212322
fatalIfError(cmd.MarkFlagRequired(ArgRPCURL))
@@ -2554,7 +2555,7 @@ or if it's actually an intermediate hash.`,
25542555
inputUlxlyArgs.timeout = ulxlyBridgeAndClaimCmd.PersistentFlags().Uint64(ArgTimeout, 60, "the amount of time to wait while trying to confirm a transaction receipt")
25552556
inputUlxlyArgs.gasPrice = ulxlyBridgeAndClaimCmd.PersistentFlags().String(ArgGasPrice, "", "the gas price to be used")
25562557
inputUlxlyArgs.dryRun = ulxlyBridgeAndClaimCmd.PersistentFlags().Bool(ArgDryRun, false, "do all of the transaction steps but do not send the transaction")
2557-
inputUlxlyArgs.insecure = ulxlyBridgeAndClaimCmd.PersistentFlags().Bool("insecure", false, "skip TLS certificate verification")
2558+
inputUlxlyArgs.insecure = ulxlyBridgeAndClaimCmd.PersistentFlags().Bool(ArgInsecure, false, "skip TLS certificate verification")
25582559
fatalIfError(ulxlyBridgeAndClaimCmd.MarkPersistentFlagRequired(ArgBridgeAddress))
25592560

25602561
// bridge specific args

0 commit comments

Comments
 (0)