@@ -18,7 +18,6 @@ package abi
1818
1919import (
2020 "encoding/binary"
21- "encoding/hex"
2221 "errors"
2322 "fmt"
2423 "math"
@@ -416,25 +415,25 @@ func toString(index int, t Type, output []byte) (interface{}, error) {
416415 }
417416 return strconv .FormatBool (b ), nil
418417 case AddressTy :
419- return hex . EncodeToString (common .BytesToAddress (returnOutput ).Bytes ()), nil
418+ return common . Bytes2HexWithPrefix (common .BytesToAddress (returnOutput ).Bytes ()), nil
420419 case HashTy :
421- return hex . EncodeToString (common .BytesToHash (returnOutput ).Bytes ()), nil
420+ return common . Bytes2HexWithPrefix (common .BytesToHash (returnOutput ).Bytes ()), nil
422421 case BytesTy :
423- return hex . EncodeToString (output [begin : begin + length ]), nil
422+ return common . Bytes2HexWithPrefix (output [begin : begin + length ]), nil
424423 case FixedBytesTy :
425424 var b interface {}
426425 b , err = ReadFixedBytes (t , returnOutput )
427426 if err != nil {
428427 return nil , fmt .Errorf ("abi: cannot convert value as fixed bytes array: %v" , returnOutput )
429428 }
430- return hex . EncodeToString (b .([]byte )), nil
429+ return common . Bytes2HexWithPrefix (b .([]byte )), nil
431430 case FunctionTy :
432431 var f interface {}
433432 f , err = ReadFixedBytes (t , returnOutput )
434433 if err != nil {
435434 return nil , fmt .Errorf ("abi: cannot convert value as function: %v" , returnOutput )
436435 }
437- return hex . EncodeToString (f .([]byte )), nil
436+ return common . Bytes2HexWithPrefix (f .([]byte )), nil
438437 default :
439438 return nil , fmt .Errorf ("abi: unknown type %v" , t .T )
440439 }
0 commit comments