From 8f97085e113e6c06e141e727093dea6d58c9d14a Mon Sep 17 00:00:00 2001 From: Goran Rojovic Date: Wed, 20 Mar 2024 10:50:06 +0100 Subject: [PATCH] Lint fix --- e2e-polybft/e2e/jsonrpc_test.go | 4 ++-- jsonrpc/codec.go | 8 ++++---- jsonrpc/types.go | 3 +++ types/access_list_tx.go | 2 ++ types/base_tx.go | 1 + types/json_unmarshal.go | 2 ++ 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/e2e-polybft/e2e/jsonrpc_test.go b/e2e-polybft/e2e/jsonrpc_test.go index b9e6f51312..509e50b63c 100644 --- a/e2e-polybft/e2e/jsonrpc_test.go +++ b/e2e-polybft/e2e/jsonrpc_test.go @@ -445,13 +445,13 @@ func TestE2E_JsonRPC_NewEthClient(t *testing.T) { require.NoError(t, err) t.Run("eth_blockNumber", func(t *testing.T) { - cluster.WaitForBlock(epochSize, 15*time.Second) + require.NoError(t, cluster.WaitForBlock(epochSize, 15*time.Second)) blockNumber, err := newEthClient.BlockNumber() require.NoError(t, err) require.GreaterOrEqual(t, blockNumber, epochSize) - cluster.WaitForBlock(blockNumber+1, 5*time.Second) + require.NoError(t, cluster.WaitForBlock(blockNumber+1, 5*time.Second)) blockNumber, err = newEthClient.BlockNumber() require.NoError(t, err) diff --git a/jsonrpc/codec.go b/jsonrpc/codec.go index 427585095b..9b45b88293 100644 --- a/jsonrpc/codec.go +++ b/jsonrpc/codec.go @@ -172,12 +172,12 @@ type BlockNumberOrHash struct { } // String returns the string representation of the block number or hash -func (b BlockNumberOrHash) String() string { - if b.BlockNumber != nil { - return b.BlockNumber.String() +func (bnh BlockNumberOrHash) String() string { + if bnh.BlockNumber != nil { + return bnh.BlockNumber.String() } - return b.BlockHash.String() + return bnh.BlockHash.String() } // UnmarshalJSON will try to extract the filter's data. diff --git a/jsonrpc/types.go b/jsonrpc/types.go index 56b0678eaa..46b98b7cfd 100644 --- a/jsonrpc/types.go +++ b/jsonrpc/types.go @@ -476,6 +476,7 @@ func (s StateOverride) MarshalJSON() ([]byte, error) { defer a.Reset() o := a.NewObject() + for addr, obj := range s { oo := a.NewObject() if obj.Nonce != nil { @@ -512,6 +513,7 @@ func (s StateOverride) MarshalJSON() ([]byte, error) { } res := o.MarshalTo(nil) + defaultArena.Put(a) return res, nil @@ -569,6 +571,7 @@ func (c *CallMsg) MarshalJSON() ([]byte, error) { } res := o.MarshalTo(nil) + defaultArena.Put(a) return res, nil diff --git a/types/access_list_tx.go b/types/access_list_tx.go index 0d7aa1d063..2c601704f3 100644 --- a/types/access_list_tx.go +++ b/types/access_list_tx.go @@ -133,6 +133,7 @@ func (t *TxAccessList) unmarshalJSON(v *fastjson.Value) error { for _, elem := range elems { accessTuple := AccessTuple{} + addr, err := unmarshalJSONAddr(elem, "address") if err != nil { return err @@ -146,6 +147,7 @@ func (t *TxAccessList) unmarshalJSON(v *fastjson.Value) error { } accessTuple.StorageKeys = make([]Hash, len(storage)) + for indx, stg := range storage { b, err := stg.StringBytes() if err != nil { diff --git a/types/base_tx.go b/types/base_tx.go index 14421d072e..982c68e4c6 100644 --- a/types/base_tx.go +++ b/types/base_tx.go @@ -127,6 +127,7 @@ func (tx *BaseTx) unmarshalJSON(v *fastjson.Value) error { if hasKey(v, "to") { if v.Get("to").String() != "null" { var to Address + if to, err = unmarshalJSONAddr(v, "to"); err != nil { return err } diff --git a/types/json_unmarshal.go b/types/json_unmarshal.go index c362e24a2f..3d57b89df9 100644 --- a/types/json_unmarshal.go +++ b/types/json_unmarshal.go @@ -232,6 +232,7 @@ func (r *Receipt) UnmarshalJSON(buf []byte) error { // logs r.Logs = r.Logs[:0] + for _, elem := range v.GetArray("logs") { log := new(Log) if err := log.unmarshalJSON(elem); err != nil { @@ -269,6 +270,7 @@ func (r *Log) unmarshalJSON(v *fastjson.Value) error { } r.Topics = r.Topics[:0] + for _, topic := range v.GetArray("topics") { b, err := topic.StringBytes() if err != nil {