Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
Signed-off-by: Philip-21 <[email protected]>
  • Loading branch information
Philip-21 committed Feb 6, 2024
1 parent 846893c commit 813c826
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pkg/types/hex_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type HexWrapper struct {
}

// WrapHexAddress wraps a hex address as HexAddress
func (h *HexWrapper) WrapHexAddress(addr [20]byte) (string, error) {
func (h *HexWrapper) WrapHexAddress(addr []byte) (string, error) {
hexStr := "0x" + hex.EncodeToString(addr[:])
// Initialize addrStr before using it
h.addrStr = new(ethtypes.Address0xHex)
Expand All @@ -53,9 +53,9 @@ func (ht *HexType) MarshalYAML() (interface{}, error) {
return nil, err
}
//copy bytes to fixed array
var hexArray [20]byte
var hexArray []byte
copy(hexArray[:], hexBytes)
hexAddr, err := ht.HexWrap.WrapHexAddress([20]byte(hexArray))
hexAddr, err := ht.HexWrap.WrapHexAddress([]byte(hexArray))
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/types/hex_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func TestWrapHexAddress(t *testing.T) {
t.Fatalf("expected 20 bytes, got %d bytes", len(hexBytes))
}
// Copy bytes to a fixed-size array
var hexArray [20]byte
var hexArray []byte
copy(hexArray[:], hexBytes)
//encodes the decoded values to hexadecimal and returns string
//Ethereum convention for representing hexadecimal values, the prefix must have "0x"
result, err := hexType.HexWrap.WrapHexAddress([20]byte(hexArray))
result, err := hexType.HexWrap.WrapHexAddress([]byte(hexArray))
if err != nil {
t.Log("error in generating result", err)
t.Fail()
Expand Down Expand Up @@ -105,9 +105,9 @@ func TestYamlMarshal(t *testing.T) {
if err != nil {
t.Log("unable to decode values")
}
var hexArray [20]byte
var hexArray []byte
copy(hexArray[:], hexbyte)
YamlHex, err := hexType.HexWrap.WrapHexAddress([20]byte(hexArray))
YamlHex, err := hexType.HexWrap.WrapHexAddress([]byte(hexArray))
if err != nil {
t.Log("unable to generate yaml string")
}
Expand Down

0 comments on commit 813c826

Please sign in to comment.