Skip to content

Commit

Permalink
fix: remove unused files
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Aug 30, 2024
1 parent 2a4f15e commit 3799575
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 304 deletions.
8 changes: 8 additions & 0 deletions common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package common

const (
// Base10 decimal base
Base10 = 10
// Gwei represents 1000000000 wei
Gwei = 1000000000
)
15 changes: 0 additions & 15 deletions config/types/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package types

import (
"time"

"github.com/invopop/jsonschema"
)

// Duration is a wrapper type that parses time duration from text.
Expand All @@ -25,16 +23,3 @@ func (d *Duration) UnmarshalText(data []byte) error {
func NewDuration(duration time.Duration) Duration {
return Duration{duration}
}

// JSONSchema returns a custom schema to be used for the JSON Schema generation of this type
func (Duration) JSONSchema() *jsonschema.Schema {
return &jsonschema.Schema{
Type: "string",
Title: "Duration",
Description: "Duration expressed in units: [ns, us, ms, s, m, h, d]",
Examples: []interface{}{
"1m",
"300ms",
},
}
}
110 changes: 0 additions & 110 deletions encoding/encoding.go

This file was deleted.

6 changes: 3 additions & 3 deletions etherman/etherscan/etherscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"math/big"
"net/http"

"github.com/0xPolygonHermez/zkevm-ethtx-manager/encoding"
"github.com/0xPolygonHermez/zkevm-ethtx-manager/common"
)

type etherscanResponse struct {
Expand Down Expand Up @@ -73,6 +73,6 @@ func (e *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
if err != nil {
return big.NewInt(0), fmt.Errorf("Reading body failed: %w", err)
}
fgp, _ := big.NewInt(0).SetString(resBody.Result.FastGasPrice, encoding.Base10)
return new(big.Int).Mul(fgp, big.NewInt(encoding.Gwei)), nil
fgp, _ := big.NewInt(0).SetString(resBody.Result.FastGasPrice, common.Base10)
return new(big.Int).Mul(fgp, big.NewInt(common.Gwei)), nil
}
6 changes: 3 additions & 3 deletions etherman/ethgasstation/ethgasstation.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"math/big"
"net/http"

"github.com/0xPolygonHermez/zkevm-ethtx-manager/encoding"
"github.com/0xPolygonHermez/zkevm-ethtx-manager/common"
)

type ethGasStationResponse struct {
Expand Down Expand Up @@ -57,8 +57,8 @@ func (e *Client) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
// Unmarshal result
err = json.Unmarshal(body, &resBody)
if err != nil {
return big.NewInt(0), fmt.Errorf("Reading body failed: %w", err)
return big.NewInt(0), fmt.Errorf("reading body failed: %w", err)
}
fgp := big.NewInt(0).SetUint64(resBody.GasPrice.Instant)
return new(big.Int).Mul(fgp, big.NewInt(encoding.Gwei)), nil
return new(big.Int).Mul(fgp, big.NewInt(common.Gwei)), nil
}
19 changes: 19 additions & 0 deletions ethtxmanager/monitoredtx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto/kzg4844"
"github.com/stretchr/testify/assert"
)
Expand Down Expand Up @@ -76,3 +77,21 @@ func TestBlobTx(t *testing.T) {
assert.Equal(t, blobGas, tx.BlobGas())
assert.Equal(t, blobGasPrice, tx.BlobGasFeeCap())
}

func TestAddHistory(t *testing.T) {
tx := types.NewTransaction(0, common.Address{}, big.NewInt(0), 0, big.NewInt(0), nil)
mTx := monitoredTx{
History: make(map[common.Hash]bool),
}

err := mTx.AddHistory(tx)
assert.NoError(t, err)

// Adding the same transaction again should return an error
err = mTx.AddHistory(tx)
assert.ErrorContains(t, err, "already exists")

// should have only one history
historySlice := mTx.historyHashSlice()
assert.Len(t, historySlice, 1)
}
121 changes: 0 additions & 121 deletions hex/hex.go

This file was deleted.

52 changes: 0 additions & 52 deletions hex/hex_test.go

This file was deleted.

0 comments on commit 3799575

Please sign in to comment.