From 8daf35ff1c4bb1841e5470f135eddee169b1e725 Mon Sep 17 00:00:00 2001 From: olumuyiwadad Date: Fri, 17 Sep 2021 18:53:18 +0530 Subject: [PATCH] fix error in address prefix hasXDCPrefix --- common/types.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/common/types.go b/common/types.go index b968b8a300..91b1ba550b 100644 --- a/common/types.go +++ b/common/types.go @@ -165,6 +165,9 @@ func HexToAddress(s string) Address { return BytesToAddress(FromHex(s)) } // IsHexAddress verifies whether a string can represent a valid hex-encoded // Ethereum address or not. func IsHexAddress(s string) bool { + if hasXDCPrefix(s) { + s = s[3:] + } if hasHexPrefix(s) { s = s[2:] } @@ -196,7 +199,7 @@ func (a Address) Hex() string { result[i] -= 32 } } - return "0x" + string(result) + return "xdc" + string(result) } // String implements the stringer interface and is used also by the logger. @@ -230,7 +233,7 @@ func (a *Address) Set(other Address) { // MarshalText returns the hex representation of a. func (a Address) MarshalText() ([]byte, error) { - return hexutil.Bytes(a[:]).MarshalText() + return hexutil.Bytes(a[:]).MarshalXDCText() } // UnmarshalText parses a hash in hex syntax.