From 59b55e06525cafa9060a2f0dba90559f99222b18 Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Tue, 27 Jun 2017 15:40:32 -0500 Subject: [PATCH] accounts/abi: begin redo Signed-off-by: RJ Catalano --- accounts/abi/abi.go | 4 ++++ accounts/abi/unpack.go | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index 2a06d474b8..97bd0582aa 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -93,6 +93,10 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) error { return fmt.Errorf("abi: unmarshalling empty output") } + if len(output)%32 != 0 { + return nil, fmt.Errorf("abi: improperly formatted output") + } + // make sure the passed value is a pointer valueOf := reflect.ValueOf(v) if reflect.Ptr != valueOf.Kind() { diff --git a/accounts/abi/unpack.go b/accounts/abi/unpack.go index 51a0d43684..0fac8686e9 100644 --- a/accounts/abi/unpack.go +++ b/accounts/abi/unpack.go @@ -98,10 +98,11 @@ func toGoSlice(i int, t Argument, output []byte) (interface{}, error) { case FixedBytesTy: inter = returnOutput case SliceTy, ArrayTy: - inter, err = toGoSlice(i+index/32, t, output) + fmt.Println("Index: ", i+index/32) + /*inter, err = toGoSlice(i+index/32, t, output) if err != nil { return nil, err - } + }*/ default: return nil, fmt.Errorf("abi: unsupported slice type passed in") } @@ -163,9 +164,6 @@ func readBool(word []byte) (bool, error) { // toGoType parses the input and casts it to the proper type defined by the ABI // argument in T. func toGoType(i int, t Argument, output []byte) (interface{}, error) { - if len(output)%32 != 0 { - return nil, fmt.Errorf("abi: improperly formatted output") - } // we need to treat slices differently if (t.Type.IsSlice || t.Type.IsArray) && t.Type.T != BytesTy && t.Type.T != StringTy && t.Type.T != FixedBytesTy && t.Type.T != FunctionTy { return toGoSlice(i, t, output) @@ -215,3 +213,5 @@ func toGoType(i int, t Argument, output []byte) (interface{}, error) { } return nil, fmt.Errorf("abi: unknown type %v", t.Type.T) } + +// this needs a near complete redo