From 886b51c97658d25c71dbdd9f1810fdd286257474 Mon Sep 17 00:00:00 2001 From: RJ Catalano Date: Sun, 11 Jun 2017 14:49:44 -0500 Subject: [PATCH] accounts/abi: various fixes throughout the package on the path to compilation. Signed-off-by: RJ Catalano --- accounts/abi/abi.go | 6 ++---- accounts/abi/parsing.go | 2 +- accounts/abi/type.go | 19 ++++++++++++------- accounts/abi/unpacking.go | 1 + 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go index 1682e8e2c1..ada9b82286 100644 --- a/accounts/abi/abi.go +++ b/accounts/abi/abi.go @@ -17,13 +17,10 @@ package abi import ( - "encoding/binary" "encoding/json" "fmt" "io" - "math/big" "reflect" - "strings" "github.com/ethereum/go-ethereum/common" ) @@ -101,7 +98,8 @@ func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) { if method, ok := abi.Methods[name]; ok { err = method.unpack(v, output) } else if event, ok := abi.Events[name]; ok { - err = event.unpackLog(v, output) + //err = event.unpackLog(v, output) // to create + err = fmt.Errorf("abi: could not find requested method or event %v", name) } else { err = fmt.Errorf("abi: could not find requested method or event %v", name) } diff --git a/accounts/abi/parsing.go b/accounts/abi/parsing.go index 66911154c6..f6d12f8d77 100644 --- a/accounts/abi/parsing.go +++ b/accounts/abi/parsing.go @@ -24,7 +24,7 @@ import ( // separates byte slice into a slice of 32 byte slices. func chunkBytes(output []byte) (chunked [][32]byte) { for i, j := 0, 0; i < len(output); i, j = i+32, j+1 { - chunked[j] = output[i : i+32] + copy(chunked[j][:], output[i:i+32]) } return } diff --git a/accounts/abi/type.go b/accounts/abi/type.go index a9b26e0cae..005f284972 100644 --- a/accounts/abi/type.go +++ b/accounts/abi/type.go @@ -29,6 +29,7 @@ const ( BoolTy StringTy SliceTy + //StructTy AddressTy FixedBytesTy BytesTy @@ -39,15 +40,19 @@ const ( // Type is the reflection of the supported argument type type Type struct { - IsSlice, IsArray bool - SliceSize int + // Slice descriptions + IsArray bool //todo: change to IsStatic + IsSlice bool //todo: change to IsDynamic + IsDoublySliced bool //todo: find a better name + SliceSize int + // If applicable (struct, slice), the underlying type Elem *Type - Kind reflect.Kind - Type reflect.Type - Size int - T byte // Our own type checking + Kind reflect.Kind // corresponding go Kind. + Type reflect.Type // corresponding go Type. + Size int // type size (denotes uint256, uint248, etc.) + T byte // Our own type checking stringKind string // holds the unparsed string for deriving signatures } @@ -65,7 +70,7 @@ var ( // string int uint fixed // string32 int8 uint8 uint[] // address int256 uint256 fixed128x128[2] - fullTypeRegex = regexp.MustCompile(`([a-zA-Z0-9]+)(\[([0-9]*)\])?`) + fullTypeRegex = regexp.MustCompile(`([a-zA-Z0-9]+)(\[([0-9]*)\])?(\[([0-9]*)\])?`) // typeRegex parses the abi sub types typeRegex = regexp.MustCompile("([a-zA-Z]+)(([0-9]+)(x([0-9]+))?)?") ) diff --git a/accounts/abi/unpacking.go b/accounts/abi/unpacking.go index d2c7b0802f..6189cc37b1 100644 --- a/accounts/abi/unpacking.go +++ b/accounts/abi/unpacking.go @@ -3,6 +3,7 @@ package abi import ( "encoding/binary" "fmt" + "math/big" "reflect" "github.com/ethereum/go-ethereum/common"