From 693be4887311309ac85ff960049364987cf086c9 Mon Sep 17 00:00:00 2001 From: alex <152680487+bodhi-crypo@users.noreply.github.com> Date: Wed, 24 Apr 2024 21:25:45 +0800 Subject: [PATCH] chore(pkg): replace `fmt.Errorf()` with `errors.New()` if no param required (#759) --- pkg/rpc/methods.go | 8 ++++---- prover/anchor_tx_validator/anchor_tx_validator.go | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/rpc/methods.go b/pkg/rpc/methods.go index a8f6b8b64..b5af64a34 100644 --- a/pkg/rpc/methods.go +++ b/pkg/rpc/methods.go @@ -638,7 +638,7 @@ func (c *Client) getSyncedL1SnippetFromAnchor( common.Hash{}, 0, 0, - fmt.Errorf("failed to parse l1BlockHash from anchor transaction calldata") + errors.New("failed to parse l1BlockHash from anchor transaction calldata") } l1StateRoot, ok = args["_l1StateRoot"].([32]byte) if !ok { @@ -646,7 +646,7 @@ func (c *Client) getSyncedL1SnippetFromAnchor( common.Hash{}, 0, 0, - fmt.Errorf("failed to parse l1StateRoot from anchor transaction calldata") + errors.New("failed to parse l1StateRoot from anchor transaction calldata") } l1Height, ok = args["_l1BlockId"].(uint64) if !ok { @@ -654,7 +654,7 @@ func (c *Client) getSyncedL1SnippetFromAnchor( common.Hash{}, 0, 0, - fmt.Errorf("failed to parse l1Height from anchor transaction calldata") + errors.New("failed to parse l1Height from anchor transaction calldata") } parentGasUsed, ok = args["_parentGasUsed"].(uint32) if !ok { @@ -662,7 +662,7 @@ func (c *Client) getSyncedL1SnippetFromAnchor( common.Hash{}, 0, 0, - fmt.Errorf("failed to parse parentGasUsed from anchor transaction calldata") + errors.New("failed to parse parentGasUsed from anchor transaction calldata") } return l1BlockHash, l1StateRoot, l1Height, parentGasUsed, nil diff --git a/prover/anchor_tx_validator/anchor_tx_validator.go b/prover/anchor_tx_validator/anchor_tx_validator.go index e5307a912..54058f16e 100644 --- a/prover/anchor_tx_validator/anchor_tx_validator.go +++ b/prover/anchor_tx_validator/anchor_tx_validator.go @@ -2,6 +2,7 @@ package anchortxvalidator import ( "context" + "errors" "fmt" "math/big" @@ -69,7 +70,7 @@ func (v *AnchorTxValidator) GetAndValidateAnchorTxReceipt( } if len(receipt.Logs) == 0 { - return nil, fmt.Errorf("no event found in TaikoL2.anchor transaction receipt") + return nil, errors.New("no event found in TaikoL2.anchor transaction receipt") } return receipt, nil