Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ogtownsend committed Oct 21, 2024
1 parent 3014ee4 commit 7139964
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions core/chains/evm/gas/rollups/custom_calldata_da_oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package rollups
import (
"context"
"encoding/hex"
"errors"
"fmt"
"math/big"
"strings"
Expand Down Expand Up @@ -44,7 +45,7 @@ func NewCustomCalldataDAOracle(lggr logger.Logger, ethClient l1OracleClient, cha
return nil, fmt.Errorf("expected %s oracle type, got %s", toml.DAOracleCustomCalldata, daOracleConfig.OracleType())
}
if daOracleConfig.CustomGasPriceCalldata() == "" {
return nil, fmt.Errorf("CustomGasPriceCalldata is required")
return nil, errors.New("CustomGasPriceCalldata is required")
}
return &customCalldataDAOracle{
client: ethClient,
Expand Down Expand Up @@ -137,15 +138,15 @@ func (o *customCalldataDAOracle) GasPrice(_ context.Context) (daGasPrice *assets
o.daGasPriceMu.RUnlock()
})
if !ok {
return daGasPrice, fmt.Errorf("DAGasOracle is not started; cannot estimate gas")
return daGasPrice, errors.New("DAGasOracle is not started; cannot estimate gas")
}
if daGasPrice == nil {
return daGasPrice, fmt.Errorf("failed to get DA gas price; gas price not set")
return daGasPrice, errors.New("failed to get DA gas price; gas price not set")
}
// Validate the price has been updated within the pollPeriod * 2
// Allowing double the poll period before declaring the price stale to give ample time for the refresh to process
if time.Since(timestamp) > o.pollPeriod*2 {
return daGasPrice, fmt.Errorf("gas price is stale")
return daGasPrice, errors.New("gas price is stale")
}
return
}
Expand All @@ -155,14 +156,14 @@ func (o *customCalldataDAOracle) getCustomCalldataGasPrice(ctx context.Context)
calldata := strings.TrimPrefix(o.daOracleConfig.CustomGasPriceCalldata(), "0x")
calldataBytes, err := hex.DecodeString(calldata)
if err != nil {
return nil, fmt.Errorf("failed to decode custom fee method calldata: %w", err)
return nil, fmt.Errorf("failed to decode custom fee method calldata: %v", err)

Check failure on line 159 in core/chains/evm/gas/rollups/custom_calldata_da_oracle.go

View workflow job for this annotation

GitHub Actions / lint

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}
b, err := o.client.CallContract(ctx, ethereum.CallMsg{
To: &daOracleAddress,
Data: calldataBytes,
}, nil)
if err != nil {
return nil, fmt.Errorf("custom fee method call failed: %w", err)
return nil, fmt.Errorf("custom fee method call failed: %v", err)

Check failure on line 166 in core/chains/evm/gas/rollups/custom_calldata_da_oracle.go

View workflow job for this annotation

GitHub Actions / lint

non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
}
return new(big.Int).SetBytes(b), nil
}
4 changes: 2 additions & 2 deletions core/chains/evm/gas/rollups/custom_calldata_da_oracle_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package rollups

import (
"fmt"
"errors"
"math/big"
"testing"

Expand Down Expand Up @@ -94,7 +94,7 @@ func TestCustomCalldataDAOracle_getCustomCalldataGasPrice(t *testing.T) {
oracle, err := NewCustomCalldataDAOracle(logger.Test(t), ethClient, chaintype.ChainCelo, daOracleConfig)
require.NoError(t, err)

ethClient.On("CallContract", mock.Anything, mock.Anything, mock.Anything).Return(nil, fmt.Errorf("RPC failure")).Once()
ethClient.On("CallContract", mock.Anything, mock.Anything, mock.Anything).Return(nil, errors.New("RPC failure")).Once()

_, err = oracle.getCustomCalldataGasPrice(tests.Context(t))
require.Error(t, err)
Expand Down

0 comments on commit 7139964

Please sign in to comment.