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 66bf39c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
15 changes: 8 additions & 7 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 @@ -41,10 +42,10 @@ type customCalldataDAOracle struct {
// chains have custom DA gas calculation methods.
func NewCustomCalldataDAOracle(lggr logger.Logger, ethClient l1OracleClient, chainType chaintype.ChainType, daOracleConfig evmconfig.DAOracle) (*customCalldataDAOracle, error) {
if daOracleConfig.OracleType() != toml.DAOracleCustomCalldata {
return nil, fmt.Errorf("expected %s oracle type, got %s", toml.DAOracleCustomCalldata, daOracleConfig.OracleType())
return nil, errors.New(fmt.Sprintf("expected %s oracle type, got %s", toml.DAOracleCustomCalldata, daOracleConfig.OracleType()))

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

View workflow job for this annotation

GitHub Actions / lint

errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
}
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, errors.New(fmt.Sprintf("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

errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
}
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, errors.New(fmt.Sprintf("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

errorf: should replace errors.New(fmt.Sprintf(...)) with fmt.Errorf(...) (revive)
}
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 66bf39c

Please sign in to comment.