Skip to content

Commit

Permalink
moved w3.RandA() to w3vm.RandA()
Browse files Browse the repository at this point in the history
  • Loading branch information
lmittmann committed Jul 29, 2023
1 parent b17bf63 commit f5f7977
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
7 changes: 0 additions & 7 deletions util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package w3

import (
"crypto/rand"
"encoding/hex"
"fmt"
"math/big"
Expand Down Expand Up @@ -50,12 +49,6 @@ func APtr(hexAddress string) *common.Address {
return &addr
}

// RandA returns a random address.
func RandA() (addr common.Address) {
rand.Read(addr[:])
return addr
}

// B returns a byte slice from a hexstring or panics if the hexstring does not
// represent a valid byte slice.
//
Expand Down
12 changes: 11 additions & 1 deletion w3vm/util.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package w3vm

import "github.com/ethereum/go-ethereum/common"
import (
"crypto/rand"

"github.com/ethereum/go-ethereum/common"
)

// zero values
var (
Expand All @@ -9,6 +13,12 @@ var (
uint0 uint64
)

// RandA returns a random address.
func RandA() (addr common.Address) {
rand.Read(addr[:])
return addr
}

// nilToZero converts sets a pointer to the zero value if it is nil.
func nilToZero[T any](ptr *T) *T {
if ptr == nil {
Expand Down

0 comments on commit f5f7977

Please sign in to comment.