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