Skip to content

Commit

Permalink
bet
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdevbear committed Jul 30, 2024
1 parent 714ee40 commit 3935c7b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
24 changes: 2 additions & 22 deletions mod/primitives/pkg/math/u64.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,10 @@ import (

"github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/hex"
"github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/ssz/constants"
"github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/ssz/schema"
"github.com/berachain/beacon-kit/mod/primitives/pkg/math/log"
"github.com/berachain/beacon-kit/mod/primitives/pkg/math/pow"
)

var _ schema.SSZObject[U64] = (*U64)(nil)

//nolint:lll
type (
// U64 represents a 64-bit unsigned integer that is both SSZ and JSON
Expand Down Expand Up @@ -107,21 +104,6 @@ func (u U64) HashTreeRoot() ([32]byte, error) {
return [32]byte(buf), nil
}

// IsFixed returns true if the bool is fixed size.
func (U64) IsFixed() bool {
return true
}

// Type returns the type of the U64.
func (U64) Type() schema.SSZType {
return schema.U64()
}

// ChunkCount returns the number of chunks required to store the uint64.
func (U64) ChunkCount() uint64 {
return 1
}

// NewFromSSZ creates a new U64 from SSZ format.
func (U64) NewFromSSZ(buf []byte) (U64, error) {
//#nosec: G701 // won't realistically overflow.
Expand Down Expand Up @@ -221,8 +203,6 @@ func GweiFromWei(i *big.Int) Gwei {
}

// ToWei converts a value from Gwei to Wei.
func (u Gwei) ToWei() *big.Int {
gweiAmount := big.NewInt(0).SetUint64(u.Unwrap())
intToGwei := big.NewInt(0).SetUint64(GweiPerWei)
return gweiAmount.Mul(gweiAmount, intToGwei)
func (u Gwei) ToWei() *U256 {
return (&U256{}).Mul(NewU256(uint64(u)), NewU256(GweiPerWei))
}
10 changes: 0 additions & 10 deletions mod/primitives/pkg/math/u64_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"testing"

"github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/hex"
"github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/ssz/constants"
"github.com/berachain/beacon-kit/mod/primitives/pkg/encoding/ssz/schema"
"github.com/berachain/beacon-kit/mod/primitives/pkg/math"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -774,14 +772,6 @@ func TestU64_UnwrapPtr(t *testing.T) {
}
}

func TestU64(t *testing.T) {
var u math.U64
require.Equal(t, constants.U64Size, u.SizeSSZ())
require.True(t, u.IsFixed())
require.Equal(t, schema.U64(), u.Type())
require.Equal(t, uint64(1), u.ChunkCount())
}

func TestU64_NewFromSSZ(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit 3935c7b

Please sign in to comment.